Bird
0
0

Given these tables:

medium📝 query result Q13 of 15
SQL - Table Relationships
Given these tables:
CREATE TABLE Person (
  PersonID INT PRIMARY KEY,
  Name VARCHAR(50)
);

CREATE TABLE Passport (
  PassportID INT PRIMARY KEY,
  PersonID INT UNIQUE,
  Number VARCHAR(20),
  FOREIGN KEY (PersonID) REFERENCES Person(PersonID)
);

What does the UNIQUE constraint on PersonID in Passport ensure?
AEach person can have multiple passports
BEach passport belongs to exactly one person, and each person has at most one passport
CPersonID can be null in Passport
DPassportID can be duplicated
Step-by-Step Solution
Solution:
  1. Step 1: Understand UNIQUE on PersonID in Passport

    The UNIQUE constraint means no two rows in Passport can have the same PersonID, so one person links to at most one passport.
  2. Step 2: Analyze relationship enforced

    Since Passport has a foreign key to Person and PersonID is unique, each passport belongs to one person, and each person can have only one passport.
  3. Final Answer:

    Each passport belongs to exactly one person, and each person has at most one passport -> Option B
  4. Quick Check:

    Unique foreign key = one-to-one link [OK]
Quick Trick: UNIQUE foreign key means one-to-one link [OK]
Common Mistakes:
MISTAKES
  • Thinking one person can have many passports
  • Ignoring UNIQUE constraint effect
  • Assuming null allowed without checking

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes