BEGIN; CREATE SEQUENCE artists_id_seq; CREATE TABLE artists ( id INTEGER PRIMARY KEY DEFAULT nextval('artists_id_seq'), name VARCHAR UNIQUE); ALTER SEQUENCE artists_id_seq OWNED BY artists.id; CREATE SEQUENCE albums_id_seq; CREATE TABLE albums ( id INTEGER PRIMARY KEY DEFAULT nextval('albums_id_seq'), artist_id INTEGER REFERENCES artists (id) NULL, name VARCHAR, tracks INTEGER, UNIQUE(artist_id, name)); ALTER SEQUENCE albums_id_seq OWNED BY albums.id; CREATE SEQUENCE tracks_id_seq; CREATE TABLE tracks ( id INTEGER PRIMARY KEY DEFAULT nextval('tracks_id_seq'), artist_id INTEGER REFERENCES artists (id) NULL, album_id INTEGER REFERENCES albums (id) NULL, name VARCHAR, length INTEGER, num INTEGER, file_name VARCHAR, file_index INTEGER, UNIQUE(artist_id, name)); ALTER SEQUENCE tracks_id_seq OWNED BY tracks.id; COMMIT;