Keys

Primary Key

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

It cannot be empty and cannot have duplicates.

student id
name
join date

101

Rachel Green

2020-05-01

201

Joey Tribianni

1998-07-05

301

Monica Geller

1999-12-14

401

Cosmo Kramer

2001-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 id
course id
name

101

C1

Rachel Green

101

C2

Rachel Green

201

C2

Monica Geller

201

C3

Cosmo 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.

Last updated