...
In SQL standard there are no unsigned integers. So their support may be omitted. But should it become needed for some reason then a compressed unsigned integer must be zero-extended on decompression.
A date field occupies 3 bytes.
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
year - 15 bits as a signed two-complement number, that is 1 bit of them is a sign bit | month - 4 bits | month day - 5 bits | |||||||||||||||||||||
byte 2 | byte 1 | byte 0 |
A time field may occupy 4, 5, or 6 bytes depending on the factional part precision that may be up to a millisecond, microsecond, and nanosecond respectively.
31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
padding - 5 zero bits | hour - 5 bits | minute - 6 bits | second - 6 bits | milliseconds - 10 bits | |||||||||||||||||||||||||||
byte 3 | byte 2 | byte 1 | byte 0 |
39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
3 zero bits | hour - 5 bits | minute - 6 bits | second - 6 bits | microseconds - 20 bits | |||||||||||||||||||||||||||||||||||
byte 4 | byte 3 | byte 2 | byte 1 | byte 0 |
47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
3 zero bits | hour - 5 bits | minute - 6 bits | second - 6 bits | microseconds - 20 bits | |||||||||||||||||||||||||||||||||||||||||||
byte 5 | byte 4 | byte 3 | byte 2 | byte 1 | byte 0 |
If the number of fields is N and t is an array that stores a binary tuple we can find the answers for the following:
...