Skip to content

Instantly share code, notes, and snippets.

@indy-singh
Created December 5, 2020 17:15
Show Gist options
  • Save indy-singh/a41eef47351d8e350cf60c8a26db5b82 to your computer and use it in GitHub Desktop.
Save indy-singh/a41eef47351d8e350cf60c8a26db5b82 to your computer and use it in GitHub Desktop.
test2.sql
CREATE TABLE example.manufacturer (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE example.telephone_model (
id BIGSERIAL PRIMARY KEY,
manufacturer_id BIGINT NOT NULL,
name TEXT NOT NULL UNIQUE,
is_in_production bool NOT NULL
);
CREATE TABLE example.member (
id BIGSERIAL PRIMARY KEY,
firstname TEXT NOT NULL,
surname TEXT NOT NULL
);
CREATE TABLE example.telephone (
id BIGSERIAL PRIMARY KEY,
telephone_number TEXT NOT NULL UNIQUE,
aquired_at timestamptz NOT NULL,
model_id BIGINT NOT NULL REFERENCES example.telephone_model (id),
staff_owner_id BIGINT NULL REFERENCES example.member (id),
CHECK ( telephone_number LIKE '0%')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment