summaryrefslogtreecommitdiff
path: root/rust/scripts/populate/create_db.sql
diff options
context:
space:
mode:
authornil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-27 17:27:02 +0200
committernil0j <nil.jimeno@estudiant.fjaverianas.com>2024-09-27 17:27:02 +0200
commit4328dd17bfcd4c33a77c4405d52c3660a6c62bf5 (patch)
tree62b48c5088fac13b93a3bcdaa85f4594601cf3fe /rust/scripts/populate/create_db.sql
parentdb58cb58b5d5612ec2aa347d0f8531b26ab2e7f3 (diff)
update
Diffstat (limited to 'rust/scripts/populate/create_db.sql')
-rw-r--r--rust/scripts/populate/create_db.sql39
1 files changed, 39 insertions, 0 deletions
diff --git a/rust/scripts/populate/create_db.sql b/rust/scripts/populate/create_db.sql
new file mode 100644
index 0000000..cfde7b0
--- /dev/null
+++ b/rust/scripts/populate/create_db.sql
@@ -0,0 +1,39 @@
+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(255),
+ artist_id int,
+ release DATE,
+
+ 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;