Primary Key
Question
What is a primary key?
Hint
A table can have only one primary key.
Explanation
A primary key is a column (or set of columns) that uniquely identifies each row in a table. Properties: 1) Unique — no two rows have the same key value. 2) NOT NULL — key values cannot be NULL. 3) A table has at most one primary key. 4) Automatically creates an index for fast lookups. Composite primary keys use multiple columns (e.g., (order_id, product_id) for order items). Primary keys are crucial for relationships, updates, and deletes. Common choices: auto-increment integers, UUIDs.
Related Resources
Related Lessons
- Constraints
Learn constraints.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.