In some systems, this would be almost impossible, especially without introducing some bugs.īy using UUIDs (or another kind of universally unique ID) we can save ourselves all this headache. Let’s say we acquire a new company and that company has its own user database and they have done the same thing using integers for their user IDs, so now we have a system where a single user ID can potentially point to two different records! To fix the problem, we would have to create a new list of IDs and painstakingly go through each data store in our architecture and update the IDs. If we need a list of posts, we look in the “users” database to see what information we have about the author. Well, we need to store a user ID, so we just start storing the user’s ID in that separate database as a kind of foreign key. For example, there may be a separate database that stores social media posts and we need to know which user made the posts. That may be fine for a while, but now imagine that we introduce more services into our backend architecture. On v, my platform for developers who want to learn back-end engineering, I use UUIDs as the primary key for all database records. It reduces the chances of future ID conflicts and makes building a distributed architecture much easier. In short, if you don’t have extremely strict memory and performance requirements, I’d recommend using UUIDs instead of integer IDs. No other ID in existence should be the same as yours. By using UUIDs, you ensure that your ID is not just unique in the context of a single database table, but is unique in the universe. A universally unique identifier (UUID) is a 128-bit format for creating IDs in code that has become popular in recent years, especially when it comes to database keys. If the site is a social media platform, then each post will also have a unique ID. ![]() ![]() For example, each user on a website will its own ID. In the context of back-end web development, an ID is just a unique identifier for a record of data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |