Repaso
EspaƱol

orders.customer_id references customers.id. What is customer_id?

Options

  1. A primary key of the orders table that identifies each order
  2. A foreign key that links each order to a customer row (Correct option)
  3. The name of an index that was created on the orders table
  4. A duplicate column that should be deleted from the table

Answer

A foreign key: it links each order to a row in another table

Why

A foreign key is a column that stores the primary key of a row in another table, creating a relationship: each order belongs to one customer.

The database can enforce it: you cannot create an order for a customer that does not exist, or delete a customer who still has orders (unless you configure cascade).

Remember

Foreign key = link to a row in another table.

Key terms

Practice this question in Repaso