Module 53: Relationships and ER Diagrams

Lesson 2 of 5 · 15–25 minutes

One-to-many and one-to-one

🏠The everyday picture

A mother can have several children; each child has one mother (one-to-many). Each person has one passport, and each passport belongs to one person (one-to-one).

📘What it really is

🖱️Try it

Add an addresses table where a customer can have many addresses (home, office), and a customer_kyc table with one-to-one sensitive details. Decide which side gets the foreign key in each case, and add the UNIQUE constraint where needed.

✅Quick check

One customer has many orders. Which table gets the foreign key?

Show the answer

orders, with a customer_id column.

How do you stop a one-to-one relationship becoming one-to-many?

Show the answer

Put a UNIQUE constraint on the foreign key column.

← PreviousForeign keys
ProLearners Assist