📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

How do you enforce a one-to-one relationship in SQL if both tables already exist?

A. Remove the primary key
B. Add a junction table
C. Add a second primary key
D. Add a foreign key in one table and a UNIQUE constraint on that foreign key column ✅

Correct Answer: D. Add a foreign key in one table and a UNIQUE constraint on that foreign key column

Explanation

The foreign key creates the link and the UNIQUE constraint limits it to one row per parent, which together enforce one-to-one.