Bird
0
0

Which of the following is the correct syntax to define a FOREIGN KEY constraint when creating a table?

easy📝 Syntax Q3 of 15
SQL - Table Constraints
Which of the following is the correct syntax to define a FOREIGN KEY constraint when creating a table?
AFOREIGN KEY (column_name) REFERENCES parent_table(parent_column)
BFOREIGN KEY column_name REFERENCES parent_table(parent_column)
CFOREIGN KEY (column_name) TO parent_table(parent_column)
DFOREIGN KEY column_name TO parent_table(parent_column)"
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct foreign key syntax

    The correct syntax uses parentheses around the column name and the keyword REFERENCES.
  2. Step 2: Compare options

    Only FOREIGN KEY (column_name) REFERENCES parent_table(parent_column) uses parentheses and REFERENCES correctly; others miss parentheses or use TO instead of REFERENCES.
  3. Final Answer:

    FOREIGN KEY (column_name) REFERENCES parent_table(parent_column) -> Option A
  4. Quick Check:

    Correct syntax = parentheses + REFERENCES [OK]
Quick Trick: Use FOREIGN KEY (col) REFERENCES table(col) syntax [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around column name
  • Using TO instead of REFERENCES
  • Missing parentheses around referenced column

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes