Interview Q&A / SQL & DBMS
SQL & DBMS interview questions
Joins, keys, normalisation, indexes and transactions for placement and backend interviews.
Prefer rapid revision? Practise SQL & DBMS short interview answers →
- What is the difference between a primary key, a unique key and a foreign key?
A primary key uniquely identifies each row and cannot be NULL; a table has only one. A unique key also prevents duplicates, but a table can have many and they usually allow NULL. A foreign key is a column that must match a primary or unique key in another table, which keeps related data consistent.
BeginnerIn-depth3 min read - What do the NOT NULL, DEFAULT and CHECK constraints do?
NOT NULL forbids missing values, DEFAULT supplies a value when none is given on insert, and CHECK rejects rows whose values fail a condition. Together they keep bad data out at the database level.
BeginnerQuick answer1 min read