Recall & Review
beginner
What is a PRIMARY KEY in a PostgreSQL table?
A PRIMARY KEY is a column or set of columns that uniquely identifies each row in a table. It ensures no duplicate or NULL values exist in those columns.
Click to reveal answer
beginner
What does the SERIAL keyword do in PostgreSQL?
SERIAL creates an auto-incrementing integer column. It automatically generates a unique number for each new row inserted.
Click to reveal answer
beginner
Can a SERIAL column be used as a PRIMARY KEY?
Yes, a SERIAL column is often used as a PRIMARY KEY because it provides unique, automatically generated values for each row.
Click to reveal answer
beginner
What happens if you insert a row without specifying a value for a SERIAL column?
PostgreSQL automatically assigns the next number in the sequence to the SERIAL column for that row.
Click to reveal answer
intermediate
How does PostgreSQL ensure uniqueness for a PRIMARY KEY?
PostgreSQL creates a unique index on the PRIMARY KEY column(s) to prevent duplicate values and enforce uniqueness.
Click to reveal answer
What is the main purpose of a PRIMARY KEY in a table?
✗ Incorrect
A PRIMARY KEY uniquely identifies each row and does not allow NULL values.
What type of data does SERIAL create in PostgreSQL?
✗ Incorrect
SERIAL creates an auto-incrementing integer column.
If you insert a row without specifying a SERIAL column value, what happens?
✗ Incorrect
PostgreSQL automatically assigns the next number in the sequence.
Can a PRIMARY KEY column contain NULL values?
✗ Incorrect
PRIMARY KEY columns must have unique, non-NULL values.
What does PostgreSQL create automatically when you define a PRIMARY KEY?
✗ Incorrect
PostgreSQL creates a unique index to enforce uniqueness for the PRIMARY KEY.
Explain what a PRIMARY KEY is and why it is important in a database table.
Think about how you find a specific item in a list without confusion.
You got /4 concepts.
Describe how the SERIAL keyword works in PostgreSQL and how it relates to PRIMARY KEY columns.
Imagine numbering pages in a book automatically.
You got /4 concepts.