Recall & Review
beginner
What is a primary key in a database table?
A primary key is a column or a set of columns that uniquely identifies each row in a table. It ensures no two rows have the same key value.
Click to reveal answer
beginner
Can a primary key column contain NULL values?
No, a primary key column cannot contain NULL values because it must uniquely identify every row, and NULL means unknown or missing.
Click to reveal answer
intermediate
What is the difference between a primary key and a unique constraint?
A primary key uniquely identifies rows and does not allow NULLs. A unique constraint also enforces uniqueness but allows NULL values depending on the database system.
Click to reveal answer
beginner
Why is it important to have a primary key in a table?
Having a primary key helps to quickly find, update, or delete specific rows. It also helps maintain data integrity by preventing duplicate rows.
Click to reveal answer
beginner
How do you define a primary key when creating a table in SQL?
You define a primary key using the PRIMARY KEY keyword in the CREATE TABLE statement, for example: CREATE TABLE Students (ID INT PRIMARY KEY, Name VARCHAR(50));
Click to reveal answer
Which of the following is true about a primary key?
✗ Incorrect
A primary key uniquely identifies each row and cannot have NULL values.
What happens if you try to insert a duplicate value into a primary key column?
✗ Incorrect
Primary keys enforce uniqueness, so duplicates cause an error.
Which SQL keyword is used to enforce uniqueness on a column but allow NULL values?
✗ Incorrect
The UNIQUE constraint enforces uniqueness but can allow NULLs.
Can a table have more than one primary key?
✗ Incorrect
A table can have only one primary key, which can be a single or composite key.
What is a composite primary key?
✗ Incorrect
A composite primary key uses more than one column to uniquely identify rows.
Explain what a primary key is and why it is important in a database table.
Think about how you identify a person uniquely in real life.
You got /4 concepts.
Describe the difference between a primary key and a unique constraint.
Consider how strict each rule is about NULL values.
You got /4 concepts.