Posts tagged with database

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Databases: how they work, and a brief history

seldo.com

Laurie Voss, co-founder of npm, explains how databases work, what the difference is between MySQL and something like Redis, why MySQL is popular and much more!

My twitter-friend Simon had a simple question that contained much complexity: how do databases work? The result was an absurdly long thread of 70+ tweets, in which I expounded on the workings and history of databases as used by modern web developers, and Simon chimed in on each tweet with further questions and requests for clarification. The result of this collaboration was a super fun tiny explanation of databases which many people said they liked, so here it is, lightly edited for clarity.

Read more [seldo.com]

Going deep on UUIDs and ULIDs

blog.honeybadger.io

Over at the Honeybadger blog, Starr Horne wrote an interesting article on the different types of UUIDs and ULIDs.

UUIDs are and will continue to be the standard. They've been around forever, and libraries are available in every language imaginable. However, new approaches are worth considering, especially as we enter a world that's increasingly run by distributed systems. New unique-id approaches may help us solve problems that weren't prevalent at the publication of RFC4122.

Read more [blog.honeybadger.io]

Understanding how Laravel configures database connections

divinglaravel.com

Mohammed Said shows a great way on how to handle db connections in a multi tenancy Laravel app.

The majority of applications just communicate with a single database. However, a considerable portion of laravel applications communicates with multiple databases. There are some neat packages that help with managing multiple connections, but it'd be useful if we understand how database connections work in Laravel, so let's dive in.

Read more [divinglaravel.com]

Dynamic relationships in Laravel using subqueries

reinink.ca

Jonathan Reininck wrote a cool article on how you can create dynamic releationships. This technique will keep the number of queries and the memory used to a minimum.

I hope that gives you a good overview of how you can use subqueries to create dynamic relationships in Laravel. This is a powerful technique that allows you to push more work into the database layer of your app. This can have a huge impact on performance by allowing you to drastically reduce the number of database queries executed and overall memory used.

Read more [reinink.ca]

Laravel Telescope: Data too long for column ‘content’

ma.ttias.be

Mattias explains a problem we recently encountered at Oh Dear with Telescope.

For Oh Dear!, we're using Laravel Telescope as a convenient way of tracking/displaying exceptions, runs, ... It stores its exceptions in the database, so you can easily view them again. It stores those in a TEXT field in MySQL, which is limited to 2^16 bytes, or 65536 bytes. Some of our exceptions tend to be pretty long, and they were hitting this limit.

Read more [ma.ttias.be]

Eloquent MySQL views

stitcher.io

My colleague Brent explains how you can easily work with MySQL views in Laravel.

MySQL views are a way of storing queries on the database level, and producing virtual tables with them. In this post we'll look at why you want to use them and how they can be integrated in Laravel with Eloquent models.

Read more [stitcher.io]

How to rid your database of PHP class names in Eloquent's Polymorphic tables

josephsilber.com

Joseph Silber, a very active Laravel contributor, has written a new blogpost on morph maps, a feature to decouple your database from your model class names.

Polymorphic relations let you set up a relationship between many different model types, without the need for extra tables. This works by storing the "morphable type" (explained below) in the database, in addition to the morphable type's ID. By default, the morphable type stored in the database is the model's full class name. While this works, it tightly couples your database to your PHP application. Let's look at how we can instruct Eloquent to use more generic values for these morphable types.

Read more [josephsilber.com]