Keys in Database Management System

İlkay Çil
3 min readApr 6, 2021

--

KEYS in DBMS is an attribute or set of attributes that help you to identify a row(tuple) in a relation(table). Keys help you uniquely identify a row in a table by a combination of one or more columns in that table.

Types of Keys in DBMS

Let's make an example.

Table 1

In here our keys are ID, Reg_ID and E-Mail.

SUPER KEY: Super key is a set of an attribute which can uniquely identify a tuple. Super key is a superset of a candidate key. All combinations are considered super keys.For example ID,E-Mail,Reg_ID ,ID+E-Mail,E-Mail +Reg_ID,ID+Reg_ID, Reg_ID+ID +E-Mail.They’re all considered super keys.

CANDIDATE KEY: A super key with no redundant attribute is known as a candidate key. In Table 1, our candidate keys are ID, Reg_ID, E-Mail.

PRIMARY KEY is a column or group of columns in a table that uniquely identifies every row in that table. The Primary Key can’t be a duplicate meaning the same value can’t appear more than once in the table. A table cannot have more than one primary key. The Primary key is chosen from among the candidate keys.ID, Reg_ID, or e-mail can be our primary key.

ALTERNATE KEY: We choose one primary key from our Candidate keys. The remaining keys which were not chosen are Alternate Keys.

FOREIGN KEY: Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables.

Table 2

The Stu_Dep part in Table 2 becomes the primary key for Table 2. In Table 1, Stu_Dep is a foreign key.

COMPOSITE KEY: A key that has more than one attribute is known as a composite key. Any key such as primary key, super key, etc. can be called a composite key if it has more than one attribute.

Resources

Database Systems: Design, Implementation, and Management Eighth Edition

--

--

No responses yet