Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are binary Guids different from usual representation

I have the following Guid:

AAB13E97-449B-4D5B-BDE2-AC479C31B782

Using System.Guid + DbLinq + SQLite to store it the following field is added to the database.

973EB1AA-9B44-5B4D-BDE2-AC479C31B782

(Dashes added for clarity)

I can see that the last 8 bytes are in the same order, and the 3 first groups are reversed, but I don't understand why.

like image 769
Jader Dias Avatar asked Feb 15 '11 11:02

Jader Dias


People also ask

What's the difference between a GUID and a UUID?

The GUID designation is an industry standard defined by Microsoft to provide a reference number which is unique in any context. UUID is a term that stands for Universal Unique Identifier. Similarly, GUID stands for Globally Unique Identifier. So basically, two terms for the same thing.

Is a GUID unique?

A GUID is a unique number that can be used as an identifier for anything in the universe, but unlike ISBN there is no central authority - the uniqueness of a GUID relies on the algorthm that was used to generate it.

What is the format of a GUID?

All GUIDs must be authored in uppercase. The valid format for a GUID is {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} where X is a hex digit (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). Note that utilities such as GUIDGEN can generate GUIDs containing lowercase letters.

Why do GUIDs have hyphens?

The GUID is really just a number. The hyphens show you how the various components are broken down but aren't really part of the number. It's like an IP address - you can store a 32-bit number, or you can store a string with dots in it, they are equivalent. Save this answer.


1 Answers

Looking at Wikipedia's article on the subject it says:

Data4 stores the bytes in the same order as displayed in the GUID text encoding (see below), but the other three fields are reversed on little-endian systems (for example Intel CPUs).

So I conclude:

  • This happens independently from the DBMS or framework used
  • This depends on the processor architeture
  • This is by design

So the question remains:

Why on earth they designed it this way?

like image 195
Jader Dias Avatar answered Nov 04 '22 01:11

Jader Dias