Understand database relationships (one-to-one, one-to-many)

10 Database and File Concepts

Objective: Understand database relationships (one‑to‑one, one‑to‑many)

In a database, relationships describe how data in one table is connected to data in another. Think of it like a social network: your friends (rows) are linked to you (another row). We’ll look at two common types: one‑to‑one and one‑to‑many.

📚 Exam Tip: Remember that a primary key uniquely identifies a row, while a foreign key points to a primary key in another table.

One‑to‑One Relationship

A one‑to‑one relationship means that each row in Table A is linked to exactly one row in Table B, and vice versa. Imagine a passport and a person – each person has one passport, and each passport belongs to one person.

Person (Table A) Passport (Table B)
John Doe (PK: 1) Passport #123456 (FK: 1)
Jane Smith (PK: 2) Passport #654321 (FK: 2)

In LaTeX notation, this can be expressed as:
$1 \times 1$ relationship

Quick Check: If you see a column that is a primary key in one table and a foreign key in another, and both columns have the same number of rows, it’s likely a one‑to‑one relationship.

One‑to‑Many Relationship

A one‑to‑many relationship means that one row in Table A can be linked to multiple rows in Table B, but each row in Table B is linked to only one row in Table A. Think of a teacher and the students they teach.

Teacher (Table A) Student (Table B)
Ms. Lee (PK: 10) Alice (FK: 10)
Bob (FK: 10)
Mr. Kim (PK: 11) Charlie (FK: 11)

LaTeX notation:
$1 \times N$ relationship

🔍 Exam Hint: Look for a foreign key in the “many” table that references the primary key of the “one” table. The cardinality is often shown as 1:N.

Real‑World Analogy

  • 📘 One‑to‑One: A student’s student ID card and the student record – each card belongs to one student, and each record has one card.
  • 📚 One‑to‑Many: A library and its books – one library can hold many books, but each book is stored in only one library.

Exam Preparation Checklist

  1. Identify primary and foreign keys in each table.
  2. Determine the cardinality: 1:1 or 1:N.
  3. Draw a simple diagram or use a table to illustrate the relationship.
  4. Explain the real‑world meaning of the relationship.
  5. Practice converting a written description into a relational diagram.
🎓 Final Tip: When in doubt, ask yourself: “Can a single record in Table A be linked to more than one record in Table B?” If yes, it’s a one‑to‑many relationship. If no, it’s one‑to‑one. Good luck!

Revision

Log in to practice.

0 views 0 suggestions