Суперключ — это либо один, либо комбинация атрибутов, которые можно использовать для уникальной идентификации записи в базе данных . Таблица может иметь много комбинаций, которые создают суперключи.
Пример Superkey
Например, таблица с полями <Name>, <Age>, <SSN> и <Phone Extension> имеет много возможных суперключей. Три суперкейса: <SSN>, <Телефонный номер, Имя> и <SSN, Имя>.
имя | Возраст | ПЛА | Phone Ext. |
---|---|---|---|
Роберт Джонс | 43 | 123-45-6789 | 123 |
Бет Смит | 43 | 234-56-7890 | 456 |
Роберт Джонс | 18 | 345-67-8901 | +789 |
Как видите, столбцы <Name> и <Age> имеют несколько записей с одинаковой информацией. В то время как столбец <Phone Extension> может использоваться для определения личности, добавочный номер телефона можно изменить.
Типы суперключей
Of those listed in the table above, only <SSN> is a candidate key, which is a special subset of superkeys that use a minimal amount of attributes to uniquely identify a record. The other columns contain information not necessary to identify records.
The <SSN> can also be referred to as the minimal key or minimal superkey because it contains the least amount of information needed to identify an individual record. Along the same lines, a primary key can also be a superkey and a minimal key because it should uniquely pinpoint a record, and should rarely if ever, change.
If the table didn’t contain a <SSN> column then an employer could create employee numbers in order to be able to identify individuals. The new employee numbers would be called a surrogate primary key. This surrogate primary key would also serve as a superkey.