📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

Which data types must match between a foreign key and the primary key it references?

A. They must both be dates
B. They must be compatible, usually the same type and size, so values can be compared exactly ✅
C. They must both be text
D. They must be different types

Correct Answer: B. They must be compatible, usually the same type and size, so values can be compared exactly

Explanation

A foreign key can only match a primary key if their types are compatible; mismatched types prevent the constraint from working.