-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from hafiz1379/sql_based_on_uml_music_genre
Catalog of my Things | SQL Schema - Music & Genre classes + main DB
- Loading branch information
Showing
1 changed file
with
35 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,52 @@ | ||
DROP DATABASE IF EXISTS catalog_of_my_things; | ||
DROP TABLE IF EXISTS Music_album, Game, Book, Item, Label, Genre, Author; | ||
|
||
CREATE DATABASE catalog_of_my_things; | ||
|
||
CREATE TABLE Author ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
first_name VARCHAR(255) NOT NULL, | ||
last_name VARCHAR(255) NOT NULL | ||
); | ||
|
||
CREATE TABLE Genre ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(255) NOT NULL | ||
); | ||
|
||
CREATE TABLE Label ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
title VARCHAR(255), | ||
title VARCHAR(255) NOT NULL, | ||
color VARCHAR(20) | ||
); | ||
|
||
CREATE TABLE Item ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
|
||
label_id INT, | ||
publish_date DATE, | ||
archived BOOLEAN, | ||
label_id INT NOT NULL, | ||
publish_date DATE NOT NULL, | ||
archived BOOLEAN NOT NULL, | ||
|
||
FOREIGN KEY (label_id) REFERENCES Label(id) | ||
); | ||
|
||
CREATE TABLE Music_album ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
on_spotify BOOLEAN NOT NULL, | ||
item_id INT NOT NULL, | ||
FOREIGN KEY (item_id) REFERENCES Item(id) | ||
); | ||
|
||
CREATE TABLE Book ( | ||
item_id INT PRIMARY KEY, | ||
publisher VARCHAR(255), | ||
publisher VARCHAR(255) NOT NULL, | ||
cover_state VARCHAR(50), | ||
FOREIGN KEY (item_id) REFERENCES Item(id) | ||
); | ||
|
||
CREATE TABLE Game ( | ||
item_id INT PRIMARY KEY, | ||
multiplayer BIT NOT NULL, | ||
last_played_at DATE NOT NULL, | ||
FOREIGN KEY (item_id) REFERENCES Item(id) | ||
); |