Bird
0
0

You have these tables:

medium📝 Debug Q6 of 15
SQL - Table Relationships
You have these tables:
CREATE TABLE Account (AccountID INT PRIMARY KEY, Balance DECIMAL);
CREATE TABLE AccountDetails (AccountID INT, Branch VARCHAR(50), FOREIGN KEY (AccountID) REFERENCES Account(AccountID));
Why might this design cause problems enforcing a one-to-one relationship?
AAccount.AccountID is not UNIQUE
BAccountDetails.AccountID is not UNIQUE or PRIMARY KEY, allowing multiple rows per account
CForeign key is missing in AccountDetails
DBalance column should be in AccountDetails
Step-by-Step Solution
Solution:
  1. Step 1: Check constraints on AccountDetails.AccountID

    AccountDetails.AccountID is only a foreign key, not UNIQUE or PRIMARY KEY, so multiple rows can exist.
  2. Step 2: Understand one-to-one enforcement

    To enforce one-to-one, AccountDetails.AccountID must be UNIQUE or PRIMARY KEY to prevent duplicates.
  3. Final Answer:

    AccountDetails.AccountID is not UNIQUE or PRIMARY KEY, allowing multiple rows per account -> Option B
  4. Quick Check:

    One-to-one requires UNIQUE or PK on foreign key [OK]
Quick Trick: Foreign key must be UNIQUE or PK for one-to-one [OK]
Common Mistakes:
MISTAKES
  • Assuming foreign key alone enforces one-to-one
  • Confusing missing foreign key with missing uniqueness
  • Thinking Balance column placement affects relationship

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes