What makes a good or bad primary key in a database?

What is a primary key?

In the world ofdatabases, the primary key of a relational table uniquely identifies each record in the table.

Social Security Cards

Glowimages / Getty Images

Databases use keys to compare, sort, and store records, and to create relationships between records.

Choosing the primary key in a database is one of the most important steps in the process.

Primary keys may consist of a single attribute or multiple attributes in combination.

Primary keys are the unique links to related information in other tables where the primary key is used.

It must be entered when a record is created, and it should never be changed.

Each table in the database has a column or two specifically for the primary key.

The student’s unique student ID number is a good choice for a primary key in the STUDENTS table.

Some people don’t even have a Social Security Number.

However, because both of those cases are rare.

Social Security Numbers can be a good choice for a primary key.

Just remember:

FAQ

It’s the same as in a database.