Theme
Primary Color
Lesson 17

Constraint – Foreign Key – Test Relation

الأوامر التي تم كتابتها في الدرس

/* Add Constraint */
ALTER TABLE orders
ADD CONSTRAINT ordering
FOREIGN KEY(client_id) REFERENCES clients(id)
ON UPDATE CASCADE
ON DELETE CASCADE;

/* Select All Records From orders */
SELECT
  *
FROM
  orders
JOIN
  clients
ON
  clients.id = orders.client_id
WHERE
  clients.id = 1;