Home
Session 3

Relationships —
The Heart of RDBMS

Everything is connected. Your database must reflect this.

The Trap: Denormalized Design

Look familiar? This is what happens when we don't understand relationships.

STUDENT
student_id (PK)
name
course_name ← Problem!
teacher_name ← Problem!
What if a student takes 5 courses? 5 columns? 5 rows?
What if teacher "Smith" changes name to "Smyth"? Update everywhere?
What if we need teacher's email? Add column to STUDENT table?

The Fundamental Truth

Core Principle

"Reality is connected.
Tables must be connected."

A student is not a course.
A course is not a teacher.
But they relate to each other.

Three Types of Relationships

Click each to understand. These mirror how reality actually works.

One-to-One (1:1)

Examples: Citizen → Passport | Student → ID Card

Rare but exists. One entity, one unique counterpart.

One-to-Many (1:N)

Examples: One Student → Many Enrollments | One Customer → Many Orders

Most common. Parent owns children.

Many-to-Many (N:M)

Examples: Students ↔ Courses | Actors ↔ Movies

Complex. Bidirectional ownership.

Visualizing One-to-Many

The parent points to children. Children point back to parent.

STUDENT
ENROLLMENTS
1
One Student

Can have many enrollments

N
Many Enrollments

Belong to one student

The Many-to-Many Mystery

Ask yourself:

👥 Can students take many courses? YES ✓
📚 Can a course have many students? YES ✓

The Forbidden Truth

Relational databases do NOT allow many-to-many directly.

We need a secret weapon. Next week: The Junction Table.

Session 4

ERD —
Thinking Before Building

"Measure twice, cut once."

The Blueprint Philosophy

📐

ERD

The Blueprint

Planning & Design

🔨

SQL

Construction

Building & Implementation

"You don't start construction without a plan."

ERD Components

Learn the visual language. This is how database architects think.

Entity

Rectangle
Singular noun
STUDENT not STUDENTS

📝

Attributes

Atomic values
No repeating groups
Inside the rectangle

🔑

Primary Key

Underlined
Unique identifier
The DNA of the row

Relationship

Line with cardinality (1, N, M) connecting entities

Live ERD: Student Enrollment System

Watch how entities connect through relationships.

Student
student_id
name
email
1
enrolls
N
Enrollment
enrollment_id
date
grade
N
for
1
Course
course_id
title
credits

Reading the diagram: One Student has many Enrollments. Each Enrollment is for one Course. Many Enrollments can point to the same Course.

Why ERDs Save Your Life

⚠️ SQL will happily run on a bad design.
Your users will suffer later.

The consequence chain of poor design:

🔄
Duplicate Data

Update nightmares

📊
Wrong Reports

Bad decisions

🔥
Painful Fixes

Production chaos

"Hours of planning save weeks of pain."

Session 5

Why RDBMS Won
The Victory

From chaos to civilization. Why the world runs on relational databases.

The Arsenal of RDBMS

Why files failed and RDBMS conquered the world:

Feature Why It Matters
📋 Tables Structured reality. Entities modeled as they exist in the world.
🎯 Keys Identity. Every thing has a unique, unchanging DNA.
🔗 Relationships Truth. Connections mirror how reality actually works.
🛡️ Constraints Data correctness. Rules that prevent human error.
⚡ Transactions Safety. All-or-nothing operations protect data integrity.
🔍 SQL Standard access. Universal language for asking questions.

The Final Truth

"RDBMS exists because
data is more important than
code."

💾

Data persists

👥

Users depend on it

⚖️

Truth matters

The Journey

😰
Pain

Excel fails

💡
Model

Reality captured

🔗
Connect

Relationships

🛡️
Protect

Truth preserved

You now think in entities, keys, and relationships.
Welcome to the world of relational thinking.

Slide 1 / 15