Theme
Primary Color
Lesson 16

Constraint – Foreign Key – Intro

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

/* Create Table clients With 3 Fields */
CREATE TABLE clients (
    id INT NOT NULL,
    username varchar(255) UNIQUE,
    email varchar(255) UNIQUE,
    PRIMARY KEY(id)
) ENGINE = INNODB;

/* Create Table orders With 3 Fields */
CREATE TABLE orders (
    order_id INT NOT NULL,
    price varchar(255),
    client_id INT NOT NULL,
    PRIMARY KEY(order_id),
    FOREIGN KEY(client_id) REFERENCES clients(id)
) ENGINE = INNODB;