Introduction to Database Keys

In this lesson, we will highlight some of keys that are present in databases.

Keys are a very important part of the relational database model. They are used to establish and identify relationships between tables and also to uniquely identify any record or row of data inside a table.

A key can be a single attribute or a group of attributes, where the combination may act as a key.

Why do we need a key?

In real-world applications, the number of tables required for storing data is huge, and different tables are related to each other as well.

Also, tables store a lot of data. Tables generally extend to thousands of records, unsorted and unorganized.

Now, to fetch any particular record from such a dataset, you will have to apply some conditions. But what if there is duplicate data present and every time you try to fetch some data by applying certain conditions, you get the wrong data? How many trials before you get the right data?

To avoid all this, keys are defined to easily identify any row of data in a table.

Let’s try to understand what keys are all about using the example of a STUDENT table:

Get hands-on with 1200+ tech skills courses.