
There are several different types of UUIDs: We’ve focused on database examples in this article because we make a pretty awesome database, but UUIDs are also used in analytics systems, web and mobile applications, etc. UUIDs are extremely popular and widely used for a variety of different identification purposes. However, in most cases the disadvantages of using something like a sequential identifier significantly outweigh the minimal increase in storage costs that comes from using UUIDs. If minimizing storage space is absolutely mission-critical, clearly storing a sequential ID (which will probably range somewhere between 1-10 numeric characters) is going to be more efficient than storing a 36-character alphanumeric. The only significant disadvantage of UUIDs is that they take up 128 bits in memory (and often a bit more when we include metadata). As a business that aspires to operate at scale, reason #2 is also very relevant to our bookshop, because distributed databases offer the best scalability and resilience. Reason #1 alone is a good argument for using UUIDs in almost any database system.
UUID GENERATOR PHP UPDATE
Now we’ve got two order 1s, two order 2s, etc., and to resolve the issue, we’ll have to update every single ID in at least one of the two databases we’re integrating. When we go to integrate our order tables, we find that they’ve used the same system. Imagine, for example, that our little bookshop grows, and we acquire another online bookshop. This can create problems even internally if we use the same ID system for multiple tables, but it really gets messy when we start working with any kind of outside data. However, it has some major downsides:įirst, it can easily create confusion when we’re doing things like joining tables or importing new data, because the id values above aren’t unique.

We could set up sequential IDs such that the first order to come in is 1, the second is 2, and so on, like so: idĪnd this approach might work well, at least for a while, if our scale is small. As orders come in, we want to assign them an id number and store them in our orders table using that number.

To answer this question, let’s imagine we’re operating an ecommerce bookshop. (Technically, it’s not impossible that the same UUID we generate could be used somewhere else, but with 340,282,366,920,938,463,463,374,607,431,768,211,456 different possible UUIDs out there, the chances are very slim). UUIDs are widely used in part because they are highly likely to be unique globally, meaning that not only is our row’s UUID unique in our database table, it’s probably the only row with that UUID in any system anywhere.

What is a UUID?Ī UUID – that’s short for Universally Unique IDentifier, by the way – is a 36-character alphanumeric string that can be used to identify information (such as a table row). Instead, it’s a good idea to assign each row some kind of unique identifier. We wouldn’t want to use fields such as name or address as unique identifiers because it’s possible more than one customer could have the same name, or share the same address. When working with a database, it’s common practice to use some kind of id field to provide a unique identifier for each row in a table.
UUID GENERATOR PHP FREE
Get more power out of your database by learning optimal schema design in this free course.
