Schema Design & Table Relationships: Mistakes
Module: Foundational Concepts
Missing foreign keys - "I'll just store customer_id without FK constraint"
Always add FOREIGN KEY constraint
Foreign keys enforce referential integrity at database level.
Foreign keys are not optional. They enforce data integrity.
High
Allows orphaned records (orders with non-existent customers)
Wrong relationship type - Using 1:N when M:N needed
Create junction table for many-to-many
If both sides can have multiple relationships, you need M:N with junction table.
Students↔Courses, Products↔Categories need junction tables
High
Cannot store multiple relationships, violates 1NF
Using CASCADE everywhere
Choose CASCADE option based on business rules
CASCADE is dangerous. Use RESTRICT as default, CASCADE only when children are meaningless without parent.
RESTRICT is safest. CASCADE only for dependent data.
High
Accidental deletions cascade and delete large amounts of data