rust-fullstack-example icon indicating copy to clipboard operation
rust-fullstack-example copied to clipboard

The reference of foreign key in `db.sql`?

Open Jedsek opened this issue 2 years ago • 0 comments

CREATE TABLE IF NOT EXISTS owner
(
    id SERIAL PRIMARY KEY NOT NULL,
    name VARCHAR(255) NOT NULL
);

CREATE TABLE IF NOT EXISTS pet
(
    id SERIAL PRIMARY KEY NOT NULL,
    owner_id INT NOT NULL,
    name VARCHAR(255) NOT NULL,
    animal_type VARCHAR(255) NOT NULL,
    color VARCHAR(255),

    CONSTRAINT fk_pet_owner_id FOREIGN KEY (owner_id) REFERENCES pet(id)     # pet(id) -> owner(id)
);

Jedsek avatar Aug 28 '22 08:08 Jedsek