From 1db4ec7f57d6f0915ea9bd7261fcecdb2855eb02 Mon Sep 17 00:00:00 2001 From: Adrien Burgun Date: Mon, 6 Mar 2023 08:43:28 +0100 Subject: [PATCH] :sparkles: Add 'course' database --- README.md | 2 +- course/Dockerfile | 6 ++ course/coureur.csv | 12 +++ course/course.csv | 9 ++ course/create.sql | 82 ++++++++++++++++++ course/ds52-course.sql | 187 +++++++++++++++++++++++++++++++++++++++++ course/entraineur.csv | 6 ++ course/participe.csv | 34 ++++++++ emode/description.md | 20 ++++- 9 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 course/Dockerfile create mode 100644 course/coureur.csv create mode 100644 course/course.csv create mode 100644 course/create.sql create mode 100644 course/ds52-course.sql create mode 100644 course/entraineur.csv create mode 100644 course/participe.csv diff --git a/README.md b/README.md index b64cd1c..974f03d 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ which can then be imported into other MariaDB instances or into a Docker image o The currently-available images are: - [`ds52-cafe`](https://hub.docker.com/r/shadamethyst/ds52-cafe) +- [`ds52-course`](https://hub.docker.com/r/shadamethyst/ds52-course) - *ds52-gescom* (TODO) -- *ds52-course* (TODO) - [`ds53-emode`](https://hub.docker.com/r/shadamethyst/ds53-emode) ## TODO diff --git a/course/Dockerfile b/course/Dockerfile new file mode 100644 index 0000000..2925c37 --- /dev/null +++ b/course/Dockerfile @@ -0,0 +1,6 @@ +FROM mariadb:latest +ADD ds52-course.sql /docker-entrypoint-initdb.d/ds52-course.sql +ENV MARIADB_PASSWORD="course" +ENV MARIADB_USER="course" +ENV MARIADB_ROOT_PASSWORD="ds52-course-root" +ENV MARIADB_DATABASE="course" diff --git a/course/coureur.csv b/course/coureur.csv new file mode 100644 index 0000000..0624a98 --- /dev/null +++ b/course/coureur.csv @@ -0,0 +1,12 @@ +"NUMCOUREUR","NOMCOUREUR","VILLECOUREUR","NUMENTR" +1,"ALBERT","BELFORT",4 +2,"DUPONT","MULHOUSE",1 +3,"MARTIN","BELFORT",1 +4,"DURANT","MULHOUSE",2 +5,"BARREAU","MONTBELIARD",3 +6,"PARRET","SEVENANS",2 +7,"PARISSE","BELFORT",1 +8,"PARADIS","MONTBELIARD",4 +9,"MANILLE","PARIS",3 +10,"DALO","BELFORT",4 +11,"FILOU","MULHOUSE",3 diff --git a/course/course.csv b/course/course.csv new file mode 100644 index 0000000..d29efde --- /dev/null +++ b/course/course.csv @@ -0,0 +1,9 @@ +"NUMCOURSE","LIBCOURSE","VILLECOURSE","DATECOURSE" +15,"Course du Lion","MONTBELIARD","15-SEP-03" +16,"Course du Lion","BELFORT","12-SEP-04" +21,"Course du Lion","MONTBELIARD","12-SEP-05" +17,"Marathon","BELFORT","15-OCT-04" +18,"Course du tour","PARIS","17-JAN-05" +19,"Course du Territoire","BELFORT","25-JAN-05" +20,"L'alsacienne","MULHOUSE","30-JUL-05" +99,"Course UTBM","BELFORT","01-SEP-05" diff --git a/course/create.sql b/course/create.sql new file mode 100644 index 0000000..040dc36 --- /dev/null +++ b/course/create.sql @@ -0,0 +1,82 @@ +DROP TABLE IF EXISTS coureur; +CREATE TABLE coureur ( + numcoureur INT NOT NULL AUTO_INCREMENT, + nomcoureur VARCHAR(255) NOT NULL, + villecoureur VARCHAR(255) NOT NULL, + numentr INT NOT NULL, + PRIMARY KEY (numcoureur) +); + +LOAD DATA LOCAL INFILE './course/coureur.csv' INTO TABLE coureur +FIELDS TERMINATED BY ',' +ENCLOSED BY '"' +LINES TERMINATED BY '\n' +IGNORE 1 LINES +( + numcoureur, + nomcoureur, + villecoureur, + numentr +); + +DROP TABLE IF EXISTS course; +CREATE TABLE course ( + numcourse INT NOT NULL AUTO_INCREMENT, + libcourse VARCHAR(255) NOT NULL, + villecourse VARCHAR(255) NOT NULL, + datecourse DATE NOT NULL, + PRIMARY KEY (numcourse) +); + +LOAD DATA LOCAL INFILE './course/course.csv' INTO TABLE course +FIELDS TERMINATED BY ',' +ENCLOSED BY '"' +LINES TERMINATED BY '\n' +IGNORE 1 LINES +( + numcourse, + libcourse, + villecourse, + @datecourse +) +SET datecourse = STR_TO_DATE(@datecourse, "%d-%b-%y"); + +DROP TABLE IF EXISTS entraineur; +CREATE TABLE entraineur ( + numentr INT NOT NULL AUTO_INCREMENT, + nomentr VARCHAR(255) NOT NULL, + villeentr VARCHAR(255) NOT NULL, + salaireentr DECIMAL(13,2), + PRIMARY KEY (numentr) +); + +LOAD DATA LOCAL INFILE './course/entraineur.csv' INTO TABLE entraineur +FIELDS TERMINATED BY ',' +ENCLOSED BY '"' +LINES TERMINATED BY '\n' +IGNORE 1 LINES +( + numentr, + nomentr, + villeentr, + salaireentr +); + +DROP TABLE IF EXISTS participe; +CREATE TABLE participe ( + numcourse INT NOT NULL AUTO_INCREMENT, + numcoureur INT NOT NULL, + ordre INT, + PRIMARY KEY (numcourse,numcoureur) +); + +LOAD DATA LOCAL INFILE './course/participe.csv' INTO TABLE participe +FIELDS TERMINATED BY ',' +ENCLOSED BY '"' +LINES TERMINATED BY '\n' +IGNORE 1 LINES +( + numcourse, + numcoureur, + ordre +); diff --git a/course/ds52-course.sql b/course/ds52-course.sql new file mode 100644 index 0000000..4f1558f --- /dev/null +++ b/course/ds52-course.sql @@ -0,0 +1,187 @@ +-- MariaDB dump 10.19 Distrib 10.11.2-MariaDB, for Linux (x86_64) +-- +-- Host: localhost Database: course +-- ------------------------------------------------------ +-- Server version 10.11.2-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `coureur` +-- + +DROP TABLE IF EXISTS `coureur`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `coureur` ( + `numcoureur` int(11) NOT NULL AUTO_INCREMENT, + `nomcoureur` varchar(255) NOT NULL, + `villecoureur` varchar(255) NOT NULL, + `numentr` int(11) NOT NULL, + PRIMARY KEY (`numcoureur`) +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `coureur` +-- + +LOCK TABLES `coureur` WRITE; +/*!40000 ALTER TABLE `coureur` DISABLE KEYS */; +INSERT INTO `coureur` VALUES +(1,'ALBERT','BELFORT',4), +(2,'DUPONT','MULHOUSE',1), +(3,'MARTIN','BELFORT',1), +(4,'DURANT','MULHOUSE',2), +(5,'BARREAU','MONTBELIARD',3), +(6,'PARRET','SEVENANS',2), +(7,'PARISSE','BELFORT',1), +(8,'PARADIS','MONTBELIARD',4), +(9,'MANILLE','PARIS',3), +(10,'DALO','BELFORT',4), +(11,'FILOU','MULHOUSE',3); +/*!40000 ALTER TABLE `coureur` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `course` +-- + +DROP TABLE IF EXISTS `course`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `course` ( + `numcourse` int(11) NOT NULL AUTO_INCREMENT, + `libcourse` varchar(255) NOT NULL, + `villecourse` varchar(255) NOT NULL, + `datecourse` date NOT NULL, + PRIMARY KEY (`numcourse`) +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `course` +-- + +LOCK TABLES `course` WRITE; +/*!40000 ALTER TABLE `course` DISABLE KEYS */; +INSERT INTO `course` VALUES +(15,'Course du Lion','MONTBELIARD','2003-09-15'), +(16,'Course du Lion','BELFORT','2004-09-12'), +(17,'Marathon','BELFORT','2004-10-15'), +(18,'Course du tour','PARIS','2005-01-17'), +(19,'Course du Territoire','BELFORT','2005-01-25'), +(20,'L\'alsacienne','MULHOUSE','2005-07-30'), +(21,'Course du Lion','MONTBELIARD','2005-09-12'), +(99,'Course UTBM','BELFORT','2005-09-01'); +/*!40000 ALTER TABLE `course` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `entraineur` +-- + +DROP TABLE IF EXISTS `entraineur`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `entraineur` ( + `numentr` int(11) NOT NULL AUTO_INCREMENT, + `nomentr` varchar(255) NOT NULL, + `villeentr` varchar(255) NOT NULL, + `salaireentr` decimal(13,2) DEFAULT NULL, + PRIMARY KEY (`numentr`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `entraineur` +-- + +LOCK TABLES `entraineur` WRITE; +/*!40000 ALTER TABLE `entraineur` DISABLE KEYS */; +INSERT INTO `entraineur` VALUES +(1,'WEBER','BELFORT',1200.00), +(2,'HARRY','SOCHAUX',760.00), +(3,'FANNIER','BELFORT',1060.00), +(4,'DUBROCK','MONTBELIARD',1372.00), +(5,'JUSTIN','PARIS',915.00); +/*!40000 ALTER TABLE `entraineur` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `participe` +-- + +DROP TABLE IF EXISTS `participe`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `participe` ( + `numcourse` int(11) NOT NULL AUTO_INCREMENT, + `numcoureur` int(11) NOT NULL, + `ordre` int(11) DEFAULT NULL, + PRIMARY KEY (`numcourse`,`numcoureur`) +) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `participe` +-- + +LOCK TABLES `participe` WRITE; +/*!40000 ALTER TABLE `participe` DISABLE KEYS */; +INSERT INTO `participe` VALUES +(15,2,2), +(15,7,1), +(16,2,3), +(16,4,2), +(16,7,1), +(17,1,5), +(17,3,1), +(17,4,4), +(17,5,2), +(17,6,3), +(17,9,6), +(17,10,6), +(18,1,4), +(18,2,3), +(18,3,2), +(18,7,1), +(18,8,5), +(18,9,7), +(18,10,6), +(19,2,3), +(19,3,4), +(19,4,8), +(19,6,2), +(19,7,1), +(19,9,5), +(20,6,1), +(20,8,2), +(21,3,3), +(21,9,2), +(21,10,1), +(99,2,3), +(99,4,2), +(99,6,1); +/*!40000 ALTER TABLE `participe` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2023-03-06 8:29:35 diff --git a/course/entraineur.csv b/course/entraineur.csv new file mode 100644 index 0000000..2530ec2 --- /dev/null +++ b/course/entraineur.csv @@ -0,0 +1,6 @@ +"NUMENTR","NOMENTR","VILLEENTR","SALAIREENTR" +1,"WEBER","BELFORT",1200 +2,"HARRY","SOCHAUX",760 +3,"FANNIER","BELFORT",1060 +4,"DUBROCK","MONTBELIARD",1372 +5,"JUSTIN","PARIS",915 diff --git a/course/participe.csv b/course/participe.csv new file mode 100644 index 0000000..74f8fd0 --- /dev/null +++ b/course/participe.csv @@ -0,0 +1,34 @@ +"NUMCOURSE","NUMCOUREUR","ORDRE" +15,2,2 +15,7,1 +16,2,3 +16,4,2 +16,7,1 +17,1,5 +17,3,1 +17,4,4 +17,5,2 +17,6,3 +17,9,6 +17,10,6 +18,1,4 +18,2,3 +18,3,2 +18,7,1 +18,8,5 +18,9,7 +18,10,6 +19,2,3 +19,3,4 +19,6,2 +19,4,8 +19,7,1 +19,9,5 +20,6,1 +20,8,2 +21,9,2 +21,10,1 +21,3,3 +99,2,3 +99,4,2 +99,6,1 diff --git a/emode/description.md b/emode/description.md index ac21ee6..c1d15bf 100644 --- a/emode/description.md +++ b/emode/description.md @@ -69,7 +69,14 @@ PRIMARY KEY (article_code) ``` ``` -LOAD DATA LOCAL INFILE './emode/article_lookup.csv' INTO TABLE article_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (article_code, article_label, category, sale_price, family_name, family_code); +LOAD DATA LOCAL INFILE './emode/article_lookup.csv' INTO TABLE article_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ( + article_code, + article_label, + category, + sale_price, + family_name, + family_code +); ``` ## ARTICLE_LOOKUP_CRITERIA @@ -187,5 +194,14 @@ PRIMARY KEY (id) ``` ``` -LOAD DATA LOCAL INFILE './emode/shop_facts.csv' INTO TABLE shop_facts FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (id, article_code, color_code, week_key, shop_code, margin, amount_sold, quantity_sold); +LOAD DATA LOCAL INFILE './emode/shop_facts.csv' INTO TABLE shop_facts FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' ( + id, + article_code, + color_code, + week_key, + shop_code, + margin, + amount_sold, + quantity_sold +); ```