Secondary key
A secondary key is an alternative search key that, in addition to the primary key , can be used in a database system as an additional search criterion for finding one or more data records. Like any search key, a secondary key can comprise one or more attributes .
In contrast to a primary key , a secondary key is not necessarily unique. It can therefore return several data records as the result of a search.
Foreign key as secondary key
In order to efficiently carry out the search using a secondary key, it makes sense to index the attributes of the secondary key using a so-called secondary index. Secondary indices play a special role in connection with foreign keys , which refer to the primary key of another relation or the same relation. To efficiently carry out a link operation that locates the related data records of two relations on the basis of such a primary-foreign key relationship, it is helpful if the associated link partners in the foreign key can be found using a secondary index based on the attribute values in the primary key. For each attribute value in the primary key, all data records are searched that have the same attribute values in the associated foreign key.
example
An address database is searched for the name Müller as a search criterion. There are numerous hits because the name Müller is a common surname.
literature
- A. Eickler, A. Kemper: Database systems. Oldenbourg Verlag, ISBN 3-486-27392-2
Web links
- Lecture Databases at the FH Lüneburg ( Memento from October 22, 2004 in the Internet Archive )