Bird
0
0

You have two tables: Orders and Customers. You want to create a foreign key constraint from Orders.CustomerID to Customers.CustomerID. Which constraint name best follows naming conventions?

hard📝 schema Q9 of 15
SQL - Table Constraints
You have two tables: Orders and Customers. You want to create a foreign key constraint from Orders.CustomerID to Customers.CustomerID. Which constraint name best follows naming conventions?
AFK_Orders_Customers_CustomerID
BFK_CustomerID
COrdersToCustomersFK
DForeignKey1
Step-by-Step Solution
Solution:
  1. Step 1: Recall foreign key naming conventions

    Foreign key names usually start with FK, followed by source table, referenced table, and optionally column name.
  2. Step 2: Compare options for clarity and completeness

    FK_Orders_Customers_CustomerID includes FK prefix, source table, referenced table, and column name, making it clear and descriptive.
  3. Final Answer:

    FK_Orders_Customers_CustomerID -> Option A
  4. Quick Check:

    Complete FK naming = B [OK]
Quick Trick: Include source and target tables in FK name [OK]
Common Mistakes:
MISTAKES
  • Using too short or vague names
  • Ignoring referenced table in name
  • Using generic names like ForeignKey1

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes