summaryrefslogtreecommitdiff
path: root/scrap/create_db.sql
diff options
context:
space:
mode:
authornil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-26 17:22:30 +0200
committernil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-26 17:22:30 +0200
commit9d70bfed33df8ea4cd77f915454da265edccf401 (patch)
tree571bae834dc5446e3c6e0f80b2efde55a3282081 /scrap/create_db.sql
parent950bb3533cf59e074f485dfbb48fcf931e245ea6 (diff)
separate sql initial script
Diffstat (limited to 'scrap/create_db.sql')
-rw-r--r--scrap/create_db.sql38
1 files changed, 38 insertions, 0 deletions
diff --git a/scrap/create_db.sql b/scrap/create_db.sql
new file mode 100644
index 0000000..bb5dbeb
--- /dev/null
+++ b/scrap/create_db.sql
@@ -0,0 +1,38 @@
+CREATE DATABASE IF NOT EXISTS balalaika;
+USE balalaika;
+
+DROP TABLE IF EXISTS song;
+DROP TABLE IF EXISTS album;
+DROP TABLE IF EXISTS artist;
+
+CREATE TABLE artist (
+ id int NOT NULL AUTO_INCREMENT,
+ name varchar(255),
+
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE album (
+ id int NOT NULL AUTO_INCREMENT,
+ name varchar(255),
+ cover varchar(510),
+ artist_id int,
+
+ PRIMARY KEY (id),
+ FOREIGN KEY (artist_id) REFERENCES artist(id)
+);
+
+CREATE TABLE song (
+ id int NOT NULL AUTO_INCREMENT,
+ name varchar(255),
+ lyrics TEXT,
+
+ album_id int,
+
+ PRIMARY KEY (id),
+ FOREIGN KEY (album_id) REFERENCES album(id)
+);
+
+ALTER TABLE song CONVERT TO CHARACTER SET utf8;
+ALTER TABLE album CONVERT TO CHARACTER SET utf8;
+ALTER TABLE artist CONVERT TO CHARACTER SET utf8;