Using hexadecimal as ID in the database

4

From the navigation bar, we notice that Google uses hexadecimal values to identify records:

  

print above has been removed from GMail, but the same is true for other services like Google Drive.

  • What is the advantage of using hexadecimal values instead of integers?
  • What type of column is appropriate in this case: string , varchar ),
asked by anonymous 08.07.2014 / 17:56

1 answer

6
  

What is the advantage of using hexadecimal values instead of   integers?

Hexadecimal is a slightly shorter representation. For example, the following two values are identical:

999999999 DEX
3B9AC9FF  HEX

You also have a better view of the bit distribution, since each position in hexadecimal equals 4 bits:

   3    B    9    A    C    9    F    F   HEX
0011 1011 1001 1010 1100 1001 1111 1111   BIN
  

What kind of column is appropriate in this case: string (varchar), binary,   other

Usually numeric, but can be binary. Hexa is just a representation; is the case of the GUID type, which SQL Server stores as a varbinary(16) .

For an example of this type of conversion, see this answer in Stack Overflow: link

    
08.07.2014 / 18:17