DBMS & SQL · Beginner · Topic 2 of 5
Keys & Constraints
4 questions.
Your progress0%
- 1st Visit
- 0/4
- 2nd Visit
- 0/4
- Revise
- 0/4
Overview
Keys identify rows and connect tables, while constraints are rules that the database checks on every insert, update and delete, so invalid data is rejected no matter which application writes it. Interviewers expect you to define each kind of key precisely and point it out in a small table, to explain how primary keys, unique keys and foreign keys behave, and to say what happens to child rows when a parent row is deleted. Constraints such as NOT NULL, CHECK and DEFAULT appear in almost every schema-design question, so practise writing a short CREATE TABLE statement that uses each of them.
Questions
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | What are super, candidate, primary, alternate and composite keys? | Concept | Easy | Read the answer to What are super, candidate, primary, alternate and composite keys? | |||
| 2 | What is the difference between a primary key and a unique key? | Concept | Easy | Read the answer to What is the difference between a primary key and a unique key? | |||
| 3 | What are integrity constraints in DBMS? | Concept | Easy | Read the answer to What are integrity constraints in DBMS? | |||
| 4 | What is a foreign key, and what do ON DELETE CASCADE and ON DELETE SET NULL do? | Concept | Medium | Read the answer to What is a foreign key, and what do ON DELETE CASCADE and ON DELETE SET NULL do? |