1

I'm reading a database and the id are all displayed like

274438ac-9bc7-42d0-9ba2-0a83a159c9a6

, there are four "-" seperate the string. Normally, I use auto-increment to let database to generate ID for me, as primary key. I'm interesting why the database owner wants to save the id like massive string. It should have performance issue because long string, but I think it improve security. Someone knows please give me a clue. Thanks.

JimZ
  • 1,182
  • 1
  • 13
  • 30
  • 4
    I *think* it's a [GUID](http://en.wikipedia.org/wiki/Globally_unique_identifier). It's most certainly not a string, but rather its string representation for human consumption. – IInspectable Jul 15 '14 at 07:05
  • @IInspectable - I agree that it appears to be a guid. Whether it's been *stored* as a guid or a string (or a binary value) depends on what support the database has for storing these and what decisions the database designer took when implementing the database. – Damien_The_Unbeliever Jul 15 '14 at 07:06
  • @IInspectable I too first thought that it was a GUID, but it could also be a string. – AStopher Jul 15 '14 at 08:46
  • @zybox: Whether this is stored as a string or as a UUID is of little relevance. Either way it represents a globally unique ID (this is the relevant detail). Storing it as a string seems wasteful (>=36 vs. 16 bytes), and is less appropriate for comparisons (casing). Since this appears to be used as a (primary) key in a DB you can be fairly sure that it is **not** stored as a string. – IInspectable Jul 15 '14 at 09:00
  • @IInspectable Good point. It may be closer to `waTeim`'s answer, where it is a unique GUID to not just the database, but world-wide. – AStopher Jul 15 '14 at 09:07

1 Answers1

1

Appears to be to be a UUID having format as discussed here. The reason to use this format rather than a sequential number is it will be unique world-wide rather than just unique to the database. Any sort of library that expects uniqueness guaranteed by UUID would require it in that format.

Community
  • 1
  • 1
waTeim
  • 9,095
  • 2
  • 37
  • 40