Skip to content

Instantly share code, notes, and snippets.

@busypeoples
Created June 20, 2022 19:17
Show Gist options
  • Save busypeoples/a31177eda2efb1730e1a49a0fc96139c to your computer and use it in GitHub Desktop.
Save busypeoples/a31177eda2efb1730e1a49a0fc96139c to your computer and use it in GitHub Desktop.
Example PostgreSQL schema for Vinyl Record Store
CREATE TABLE artists (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
alias INT REFERENCES artists(id)
);
CREATE TABLE records (
id SERIAL PRIMARY KEY,
name TEXT,
artist INT REFERENCES artists(id) NOT NULL,
label CHAR(50) NOT NULL,
format TEXT NOT NULL CHECK (format IN ('12', '10', '7', 'lp', '2lp', '3lp', '4lp'))
);
CREATE TABLE sales (
id SERIAL PRIMARY KEY,
price INT NOT NULL,
date timestamp NOT NULL,
record INT NOT NULL REFERENCES records(id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment