Hello everyone, I hope you are all doing great. I am starting out building a Property Listing Application and my doubt is What is the best way to set primary keys in a Production database? Should I start out with plain integer values and auto-increment them or there are some best practices? I am curious how professionals plan and set primary keys for Production databases? Thank You.
No one can tell you the best option just by what you described. Also, what was the best option can change over time. So, you should learn different strategies for choosing the primary key. These strategies are better explained elsewhere. Literally, there are endless discussions about using an auto-increment key, UUID, natural key, and custom unique key.
If you are curious about how professionals do it, then you can read the posts and all the comments and start your search from there.
I think you are too early to have concern for the production database without even knowing the scale you expect. So, just build prototypes with the simplest choice (auto-increment or UUID) and defer the decision regarding production db until you gather more clues.
Thank you so much These are very good posts, I will consider your advice and start working by building prototypes rather than jumping directly to production databases.
And I am very grateful and glad to be a part of codewithmosh forum
Cool, I always have the problem of thinking too much about non-existent problems and just wasting too much time. It’s almost always better to have a small stupid thing up and running, discover the actual problems, and then try to make it better. Good luck
Agree with that! Thank you once again