Keys

Primary Key

The Attribute helps to identify a row in an entity uniquely.

It cannot be empty and cannot have duplicates.

student idnamejoin date
101Rachel Green2020-05-01
201Joey Tribianni1998-07-05
301Monica Geller1999-12-14
401Cosmo Kramer2001-06-05

Based on the above data, which attribute can be PK?

any column (as its just four rows)

If we extend the dataset to 10000 rows, which can be PK?

yes student id

Composite Key

A Primary key that consists of two or more attributes is known as a **** composite key.

student idcourse idname
101C1Rachel Green
101C2Rachel Green
201C2Monica Geller
201C3Cosmo Kramer

Do you know how to find the unique row?

The combination of StudentID + CourseID makes it unique.

Unique Key

Unique keys are similar to Primary Key, except it can allow one NULL.