Bird
0
0

Given these tables:

medium📝 Debug Q7 of 15
SQL - Table Relationships
Given these tables:
CREATE TABLE Student (StudentID INT PRIMARY KEY, Name VARCHAR(50));
CREATE TABLE StudentProfile (ProfileID INT PRIMARY KEY, StudentID INT UNIQUE, FOREIGN KEY (StudentID) REFERENCES Student(StudentID));
Why does this design enforce a one-to-one relationship?
AStudentProfile.ProfileID is separate primary key, allowing multiple profiles per student
BStudentID in StudentProfile is UNIQUE, so only one profile per student
CForeign key is missing in StudentProfile
DStudent table lacks UNIQUE constraint
Step-by-Step Solution
Solution:
  1. Step 1: Analyze primary keys and uniqueness

    StudentProfile has ProfileID PRIMARY KEY and StudentID UNIQUE FOREIGN KEY referencing Student.
  2. Step 2: Identify enforcement mechanism

    UNIQUE on StudentID prevents duplicate StudentIDs, allowing only one profile per student while FK ensures referential integrity.
  3. Final Answer:

    StudentID in StudentProfile is UNIQUE, so only one profile per student -> Option B
  4. Quick Check:

    UNIQUE on FK enforces one-to-one [OK]
Quick Trick: UNIQUE on FK enforces one-to-one even with surrogate PK [OK]
Common Mistakes:
MISTAKES
  • Thinking separate PK allows multiple profiles per student
  • Ignoring UNIQUE constraint on foreign key
  • Confusing missing foreign key with design issue

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes