5

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.

Jader Dias
  • 88,211
  • 155
  • 421
  • 625

1 Answers1

4

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?

Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 5
    "Why on earth they designed it this way?" - my guess is that originally V1 GUIDs held MAC address in the Data4 field. Historically big-endian was defined as the standard network byte order and was used in many network-related things such as IP addresses, MAC addresses, etc. – Igor Korkhov Feb 15 '11 at 12:20
  • 1
    From Wikipedia: `Version 1 (MAC address) Conceptually, the original (version 1) generation scheme for UUIDs was to concatenate the UUID version with the MAC address of the computer that is generating the UUID, and with the number of 100-nanosecond intervals since the adoption of the Gregorian calendar in the West. This scheme has been criticized in that it is not sufficiently "opaque"; it reveals both the identity of the computer that generated the UUID and the time at which it did so.` – Jader Dias Feb 15 '11 at 15:45