-
-
Save busypeoples/a31177eda2efb1730e1a49a0fc96139c to your computer and use it in GitHub Desktop.
Example PostgreSQL schema for Vinyl Record Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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