A primary key is a special column or set of columns in a relational database that uniquely identifies each row in a table. Primary keys ensure that no two rows share the same identifier and that each entry can be referenced consistently. They are often implemented as auto-incrementing integers or UUIDs for distributed systems.
Why it matters
Primary keys enforce uniqueness and support efficient lookups, indexing, and relationships. They serve as the foundation for foreign keys and normalized database design. Without a primary key, it becomes difficult to reference, update, or delete records reliably.
Examples
A user_id column in a users table or an order ID in an orders table. Lessons like Primary Keys and IDs illustrate how primary keys work.