Bird
0
0

Which of the following is the correct syntax to declare a foreign key in SQL?

easy📝 Syntax Q12 of 15
SQL - Table Relationships
Which of the following is the correct syntax to declare a foreign key in SQL?
AFOREIGN KEY column_name REFERENCES other_table
BPRIMARY KEY (column_name) REFERENCES other_table(other_column)
CFOREIGN KEY (column_name) REFERENCES other_table(other_column)
DKEY FOREIGN (column_name) REFERENCES other_table(other_column)
Step-by-Step Solution
Solution:
  1. Step 1: Recall the standard foreign key syntax

    The correct syntax includes the keywords FOREIGN KEY, the column in parentheses, then REFERENCES followed by the referenced table and column in parentheses.
  2. Step 2: Compare options to syntax

    FOREIGN KEY (column_name) REFERENCES other_table(other_column) matches the correct syntax exactly. Other options have wrong keyword order or missing parentheses.
  3. Final Answer:

    FOREIGN KEY (column_name) REFERENCES other_table(other_column) -> Option C
  4. Quick Check:

    FOREIGN KEY + REFERENCES + (table.column) = A [OK]
Quick Trick: FOREIGN KEY (col) REFERENCES table(col) is correct syntax [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around column names
  • Swapping PRIMARY KEY with FOREIGN KEY
  • Incorrect keyword order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes