Primary Keys: IDs versus GUIDs

Every wonder if you should create primary keys in a database as IDs or GUIDs?

Written by Jonathan "JD" Danylko • Last Updated: • Develop •

Developers share a lot of building duties when building applications for users including create database structures.

If you've been building databases for a while, you may run across developers who create primary keys as IDs or GUIDs, but which is better?

Jeff Atwood on my favorite blog, Coding Horror, talks about which is better to use for primary keys: IDs or GUIDs. Personally, I've been using IDs for the longest time and been on the fence about GUIDs for a while. As stated in the post, It is 16 bytes and I've been talked to about it by DBAs before because it was taking up a lot of space.

ASP.NET 8 Best Practices on Amazon

ASP.NET 8 Best Practices by Jonathan Danylko


Reviewed as a "comprehensive guide" and a "roadmap to excellence" with over 120 Best Practices for ASP.NET Core 8, Jonathan's first book by Packt Publishing explores proven techniques for every phase of the SDLC.

Learn industry-standard concepts to improve your coding, debugging, and deployment of ASP.NET Core websites.

Order now on Amazon.com button

Picture of Jonathan "JD" Danylko

Jonathan "JD" Danylko is an author, web architect, and entrepreneur who's been programming for over 30 years. He's developed websites for small, medium, and Fortune 500 companies since 1996.

He currently works at Insight Enterprises as an Architect.

When asked what he likes to do in his spare time, he replies, "I like to write and I like to code. I also like to write about code."

comments powered by Disqus