What is a primary key?
💡 Model Answer
A primary key is a column or a set of columns in a relational database table that uniquely identifies each row in that table. It must contain unique values and cannot contain NULLs. The primary key enforces entity integrity, ensuring that each record can be uniquely retrieved and referenced. It also automatically creates a unique index, which improves query performance. For example, in a "Customers" table, the "CustomerID" column is often used as the primary key. When designing a primary key, you should choose a stable, immutable value that is not likely to change over time. Composite keys can be used when a single column is insufficient to guarantee uniqueness. The primary key is also the basis for foreign key relationships in other tables, enabling referential integrity across the database schema.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500