Created
August 15, 2022 14:56
-
-
Save melnikovdv/7b1cf08bea4f0bcc708f3a7b1a1bfb89 to your computer and use it in GitHub Desktop.
SQL question
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 track( | |
id SERIAL PRIMARY KEY, | |
name VARCHAR NOT NULL | |
); | |
CREATE TABLE playlist( | |
id SERIAL PRIMARY KEY, | |
name VARCHAR NOT NULL | |
); | |
-- Many-to-many relationship: | |
-- One track can be included in several playlists | |
-- One playlists contains several tracks | |
CREATE TABLE track_to_playlist( | |
id SERIAL PRIMARY KEY, | |
trace_id INTEGER NOT NULL UNIQUE REFERENCES track(id), | |
playlist_id INTEGER NOT NULL UNIQUE REFERENCES playlist(id) | |
); | |
-- Task: write an SQL query to retrieve all tracks | |
-- which are not included into any playlist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment