March 23, 2007

Database Development: GUIDs or IDs as Primary Key?

I got quite busy so I didn't have enough time to post in this blog. Currently, I'm coding for another monitoring system device that will work in parallel with my last visual basic development on vibration monitoring. Today, I'm dealing with MySQL database that will keep all the measurement data will be updated in real time.

Something that I found on my reader today catch my interest where Jeff Atwood wrote about wether to use IDs or GUIDs for database primary keys. Before you're asking me. GUID or Globally Unique Identifier is a pseudo-random number used in software applications. The difference between normal IDs that usually in form of auto increment integer value...

ID  Value
-- -----
1 Visual Basic Programming
2 Visual C++ Programming
3 VB .NET Programming
4 C# .NET Programming
5 Java Programming

and GUID keys which most commonly written in text as a sequence of hexadecimal digits...
ID                                    Value
------------------------------------ -----
C84AC87F-842C-20EF-4D77-9F8429E95131 Visual Basic Programming
4AE8DEE4-501E-47EE-51A8-365AC5A069AC Visual C++ Programming
60E22A73-8677-4630-B3CB-12131D16635C VB .NET Programming
1515ED8C-823C-0166-8417-295981EA7158 C# .NET Programming
ED15158C-3C66-3F82-EE34-81295589EF43 Java Programming

as your database primary keys is the GUIDs will be unique across every table, every database and every server you have. This means you can easily merge records from different databases. Anyway, there is still a lot of pros and cons of using such 16-bytes GUIDs as discussed in..

But from now on, you have another option to choose for your database development.

Owh.. before I forget, as usual I'll offer great books for you to have. So, take a look at this reference manual... and enjoy!!

Share This Article:

Bookmark This Article:
Feed Me Digg Technorati Best to Stumbleupon Reddit Blinklist Furl Spurl Yahoo Simpy