📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

Which order should tables be created in when foreign keys link them?

A. Any order, foreign keys do not depend on creation order
B. Only junction tables first
C. Parent tables first, then child tables that reference them, so the referenced key exists ✅
D. Child tables first, then parent tables

Correct Answer: C. Parent tables first, then child tables that reference them, so the referenced key exists

Explanation

A foreign key cannot reference a table or key that does not yet exist, so parents are created before children.