Databases are generalized data structures. Both store data, either internally in memory or externally on disk or in the cloud. As data containers, they have a logical structure and a physical structure.
Consider the simplest of data structures: a one-dimensional array a[]
of strings. The logical structure of this is shown in Figure 10-2.
It is an object, referenced by the variable a
. Inside that object is a sequence of numbered storage compartments, each capable of holding a string object.
However, the physical structure, hidden from the programmer, is a sequence of bytes in memory. Using two-byte Unicode characters, it will allocate 16 bytes for the encodings of the characters of the eight string, and it will also store information, such as the name of the array (a
), the datatype of the elements being stored (String
), and the hexadecimal starting location of the sequence of 16 bytes, elsewhere.
The same dichotomy holds for database structures...