17.2. SQL table usage

The set of types of the columns that make up a table in the database can be thought of as a signature for that table. For example, if table T5 has 3 columns of types INTEGER, REAL, and TEXT, then the tuple (INTEGER, REAL, TEXT) is said to be the table's signature. The library makes use of this concept by storing all objects that have the same table signature in the same table, even if the table actually stores two completely different C++ object types. For example, an object of type std::pair<int, float> corresponds to the signature (INTEGER, REAL). An object of type

struct IS {
  long l;
  double d;
};

also has a signature (INTEGER, REAL). So if objects of both types are stored to the database, they will in fact be stored in the same SQL table. This minimises the need to create extra tables which in turn reduces the overall space requirements of the database file, ie, this is a space optimization.

The library does not support re-ordering of the signature types, however, so objects with signature (REAL, INTEGER) will not be stored in the same table as objects with signature (INTEGER, REAL).