Summary - Design
- SQL course
- Expert
- Lesson 6/45
- 5 min
Move from an ER model to table design.
Summary - Design
Database design starts with the ER model, continues with cardinality and key choice. The balance of surrogate and natural keys, and the denormalization call, form the core of design.
-- ER -> tablolar
-- 1:N -> FOREIGN KEY
-- M:N -> junction tableDesign steps are sequential.
Practice Summary - Design
Summary task: create the members table with id SERIAL PRIMARY KEY and email TEXT UNIQUE.
Starter code
-- summary design
CREATE TABLE membersSample solution
CREATE TABLE members (
id SERIAL PRIMARY KEY,
email TEXT UNIQUE
);Expected output
CREATE TABLE
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Surrogate key type
id ____ PRIMARY KEY
id SERIAL PRIMARY KEY
Explanation: A surrogate key is an automatic number with no business meaning; SERIAL generates it.
2 What table does an M:N relationship require?
- A procedure
- A view
- A trigger
- A junction table Correct answer
Explanation: An M:N relationship requires a junction table.
3 Summary - Design: match the terms
| Term | Meaning |
|---|---|
ER |
model |
1:N |
foreign |
M:N |
junction |
denormalize |
merge |