Bird
0
0

You want to split user data into two tables: User and UserProfile. Each user has exactly one profile. Which design best enforces this one-to-one relationship?

hard📝 Application Q15 of 15
SQL - Table Relationships
You want to split user data into two tables: User and UserProfile. Each user has exactly one profile. Which design best enforces this one-to-one relationship?
AUser and UserProfile share the same primary key column
BUserProfile has a foreign key to User without UNIQUE constraint
CUserProfile has no foreign key but a separate primary key
DUserProfile has a foreign key to User with UNIQUE constraint on that foreign key
Step-by-Step Solution
Solution:
  1. Step 1: Understand one-to-one enforcement methods

    One way is to share the same primary key in both tables, ensuring exactly one matching row.
  2. Step 2: Compare options

    User and UserProfile share the same primary key column uses the same primary key in both tables, which is a strong one-to-one design. UserProfile has a foreign key to User with UNIQUE constraint on that foreign key is valid but less strict. Options B and C do not enforce one-to-one properly.
  3. Final Answer:

    User and UserProfile share the same primary key column -> Option A
  4. Quick Check:

    Shared primary key = strict one-to-one [OK]
Quick Trick: Use shared primary key for strict one-to-one [OK]
Common Mistakes:
MISTAKES
  • Ignoring uniqueness on foreign key
  • Assuming foreign key alone enforces one-to-one
  • Not linking tables properly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes