Bird
0
0

Which of the following is the correct syntax to define a composite primary key on columns order_id and product_id in SQL?

easy📝 Syntax Q12 of 15
SQL - Table Constraints
Which of the following is the correct syntax to define a composite primary key on columns order_id and product_id in SQL?
APRIMARY KEY (order_id, product_id)
BPRIMARY KEY order_id, product_id
CPRIMARY KEY order_id & product_id
DPRIMARY KEY (order_id + product_id)
Step-by-Step Solution
Solution:
  1. Step 1: Recall SQL syntax for composite keys

    Composite keys are defined by listing columns inside parentheses separated by commas.
  2. Step 2: Match correct syntax

    PRIMARY KEY (order_id, product_id) uses parentheses and comma correctly: PRIMARY KEY (order_id, product_id).
  3. Final Answer:

    PRIMARY KEY (order_id, product_id) -> Option A
  4. Quick Check:

    Composite key syntax uses parentheses and commas [OK]
Quick Trick: Use parentheses and commas for composite keys [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around columns
  • Using symbols like & or + incorrectly
  • Listing columns without commas

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes