diff --git a/projet/data.sql b/projet/data.sql new file mode 100644 index 0000000000000000000000000000000000000000..6e614106a78b7276ea5e64f9b8321dac62acbd0f --- /dev/null +++ b/projet/data.sql @@ -0,0 +1,35 @@ +USE hyperdrive; + +INSERT INTO Users +VALUES + ("a", "test"), + ("b", "test"), + ("c", "test"), + ("d", "test"), + ("e", "test"); + +INSERT INTO Paths +VALUES + ("/a", "a", NULL), + ("/a/coucou", "a", "/a"), + ("/b", "b", NULL), + ("/c", "c", NULL), + ("/c/test", "c", "/c"), + ("/d", "d", NULL), + ("/e", "e", NULL); + +INSERT INTO Files +VALUES + ("abcd", "un", "/a"), + ("ab", "deux", "/a"), + ("@dfsg", "trois", "/c/test"), + ("gbvaf", "quatre", "/b"), + ("dsfgh", "cinq", "/d"), + ("sdfa", "six", "/e"); + +INSERT INTO Shares +VALUES + ("a", "b", "abcd"), + ("a", "c", "abcd"), + ("a", "d", "abcd"), + ("c", "e", "@dfsg"); diff --git a/projet/docker-compose.yml b/projet/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..825f578ce513199869a30d7d81201befb6feb425 --- /dev/null +++ b/projet/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' +services: + db: + image: mysql + restart: always + container_name: hyperdrive + environment: + MYSQL_ROOT_PASSWORD: super + MYSQL_DATABASE: hyperdrive + MYSQL_USER: hyperdrive + MYSQL_PASSWORD: hyper + ports: + - '3306:3306' + expose: + - 3306 + volumes: + - ./hyperdrive.sql:/docker-entrypoint-initdb.d/hyperdrive.sql \ No newline at end of file diff --git a/projet/hyperdrive.sql b/projet/hyperdrive.sql new file mode 100644 index 0000000000000000000000000000000000000000..431989eed299dc41a64b89de345f1b4465cdc6ec --- /dev/null +++ b/projet/hyperdrive.sql @@ -0,0 +1,74 @@ +CREATE DATABASE IF NOT EXISTS `hyperdrive` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `hyperdrive`; + +-- mysql -h localhost -P 3306 --protocol=tcp -u root -p +-- Creating tables + +CREATE TABLE IF NOT EXISTS Users ( + pseudo varchar(60) NOT NULL, + passwd varchar(256) NOT NULL, + PRIMARY KEY (pseudo) +); + +CREATE TABLE IF NOT EXISTS Paths ( + paths varchar(50) NOT NULL, + pseudo varchar(60) NOT NULL, + parent varchar(50), + PRIMARY KEY (paths), + FOREIGN KEY (pseudo) REFERENCES Users(pseudo), + FOREIGN KEY (parent) REFERENCES Paths(paths) +); + +CREATE TABLE IF NOT EXISTS Files ( + file_id varchar(100) NOT NULL, + file_name varchar(50) NOT NULL, + paths varchar(50) NOT NULL, + PRIMARY KEY (file_id), + FOREIGN KEY (paths) REFERENCES Paths(paths) +); + +CREATE TABLE IF NOT EXISTS Shares ( + pseudo_1 varchar(60) NOT NULL, + pseudo_2 varchar(60) NOT NULL, + file_id varchar(100) NOT NULL, + PRIMARY KEY (pseudo_1, pseudo_2, file_id), + FOREIGN KEY (pseudo_1) REFERENCES Users(pseudo), + FOREIGN KEY (pseudo_2) REFERENCES Users(pseudo), + FOREIGN KEY (file_id) REFERENCES Files(file_id) +); + +-- Inserting datas + +INSERT INTO Users +VALUES + ("a", "test"), + ("b", "test"), + ("c", "test"), + ("d", "test"), + ("e", "test"); + +INSERT INTO Paths +VALUES + ("/a", "a", NULL), + ("/a/coucou", "a", "/a"), + ("/b", "b", NULL), + ("/c", "c", NULL), + ("/c/test", "c", "/c"), + ("/d", "d", NULL), + ("/e", "e", NULL); + +INSERT INTO Files +VALUES + ("abcd", "un", "/a"), + ("ab", "deux", "/a"), + ("@dfsg", "trois", "/c/test"), + ("gbvaf", "quatre", "/b"), + ("dsfgh", "cinq", "/d"), + ("sdfa", "six", "/e"); + +INSERT INTO Shares +VALUES + ("a", "b", "abcd"), + ("a", "c", "abcd"), + ("a", "d", "abcd"), + ("c", "e", "@dfsg");