How to choose between the UUID and the sequential ID as the Primary key in Xano?
At the initial stage of creating the data table, Xano will ask to choose the primary key as UUID or the sequential ID.
There is no easy way I could find to change the existing table primary key from sequential ID to UUID which makes this decision more crucial.
What is UUID and Sequential ID?
Let's understand the basic definition in easy language:
UUID: Universally Unique IDentifier commonly known as UUID is a unique ID of 32 alphanumeric characters randomly generated by xano for every row of that table.
Sequential ID: Sequential ID is a sequential integer being created for every record in an auto-incremental manner like the first row will have the primary key as 1, the second row will have the primary key as 2, and so on...
What are the characteristics of UUID and Sequential ID?
Let's understand the basic characteristics in easy language:
UUID:
Single UUID occupies 128-bit storage which may cause performance issues while selecting queries and indexing
UUID is random and not predictable. 32 characters of UUID makes it not user-friendly
UUID is not very readable. For example: 6443 is much more readable than 7197a0d6-f47b-44e6-9359-c0bd034462aa
There will be a sense of security as malicious users cannot guess the UUID
UUIDs are not naturally sortable
UUID enables you to share data across distributed systems
UUID reduces the complexity of integration between databases
Sequential ID:
Single Sequential ID occupies far less storage than UUID which makes it more performant than UUID
Sequential ID is incremental and predictable which makes it more user-friendly
Sequential ID is naturally sortable
Sharing data across distributed systems will become too much painful and integration between databases
How to choose between the UUID and the sequential ID as the Primary key?
Here is how you should make the choice based on the information given above.
If you are considering data migration or data integration (between two more different databases) from Xano in the future, you should go with UUID. If not, then you can think about considering sequential ID as the primary key based on the following parameters.
If storage is not an issue and you are capable enough to optimize performance on a large scale then using UUID is not risky.
To optimize performance and storage, you should go with the sequential ID as the Primary key.
Primary keys that are not going to be exposed to users can be used UUID.
Usecase in which the primary key will be exposed to users, Users prefer simplicity. Sequential ID has more readability and readability leads to simplicity. Numbers are easy to write, easy to remember, and easy to communicate. For example, the order number that is inspected by the Support staff, Inventory management staff, etc.
If you can think of more parameters to consider while making this decision, feel free to share them in the comment section.
click here to connect with me.
After the Published Article Comments that provide more insight into this topic:
Credit: Caleb Lewallen
Help me!
If you enjoyed this post and found it helpful, Kindly consider supporting my work by buying me a coffee! Your support helps me create more valuable content and continue sharing useful resources. Thank you!
Subscribe to my newsletter
Read articles from Anish Gandhi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Anish Gandhi
Anish Gandhi
✔️ Certified Bubble.io Developer with 2+ Years of experience in creating scalable responsive web applications. ✔️ Top Rated Plus Upwork Freelancer ✔️ Canvas framework expert