Introduction

What is a Lookup Column? Imagine there is a relationship between two tables cars and persons. In details, it is a relationship between cars.owner field and persons.id field. Both fields are numeric: persons.id is a unique number for a person (primary key), not very interesting for a database user; cars.owner is a number that refers (as a foreign key) to the appropriate value of persons.id.

However, in our cars table, we don't want to see the numberic identifier, or require database user to enter it by hand. Instead, we would rather like to see, say, the surname of the person that is the owner of a given car. It's largely about usability of the final database product created using Kexi.

To do this, KexiDB, a database layer should contain a data structure and a logic built in that allows to define such a lightweight relation, lookup column. The relation appears on the screen as some sort of combo box widget.

Only properties having values that differ from defaults are stored. For example, since default for "show-column-headers" is false, the property is not saved if its value is false. Defaults are defined by KEXIDB_LOOKUP_FIELD_DEFAULT_* macros in kexidb/lookupfieldschema.h.

TODO: in the future defaults will be overriden by the global app
or project settings

Loading of the XML string is performed by Connection::loadExtendedTableSchemaData() in the static function LookupFieldSchema* LookupFieldSchema::loadFromXML(const QDomElement& lookupEl). Saving is provided by void LookupFieldSchema::saveToXML(LookupFieldSchema& lookupSchema, QDomElement& parentEl).