CodeBlanks Logo Icon CodeBlanks

Summary - Design

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 table

Design steps are sequential.

Practice Summary - Design

Summary task: create the members table with id SERIAL PRIMARY KEY and email TEXT UNIQUE.

Starter code

query.sql
-- summary design
CREATE TABLE members

Sample solution

query.sql
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

Question
id ____ PRIMARY KEY
Answer
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

All lessons in Expert