cuisine/db/structureCuisine.sql

132 lines
3.8 KiB
MySQL
Raw Permalink Normal View History

-- On retire les tables, dans le bon ordre !
DROP TABLE IF EXISTS `Reutilise`;
DROP TABLE IF EXISTS `RecetteUstensile`;
DROP TABLE IF EXISTS `RecettePreparation`;
DROP TABLE IF EXISTS `RecetteIngredient`;
DROP TABLE IF EXISTS `Recette`;
DROP TABLE IF EXISTS `Aime`;
DROP TABLE IF EXISTS `Preparation`;
DROP TABLE IF EXISTS `Ingredient`;
DROP TABLE IF EXISTS `Humain`;
DROP TABLE IF EXISTS `Genre`;
DROP TABLE IF EXISTS `Ustensile`;
DROP TABLE IF EXISTS `Unite`;
-- Table structure for table `Unite`
CREATE TABLE `Unite` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nom mediumtext DEFAULT NULL
);
-- Table structure for table `Ustensile`
CREATE TABLE `Ustensile` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL
);
-- Table structure for table `Genre`
CREATE TABLE `Genre` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL
);
-- Table structure for table `Humain`
CREATE TABLE `Humain` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL
);
-- Table structure for table `Ingredient`
CREATE TABLE `Ingredient` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL,
`jan` tinyint(1) DEFAULT NULL,
`fev` tinyint(1) DEFAULT NULL,
`mar` tinyint(1) DEFAULT NULL,
`avr` tinyint(1) DEFAULT NULL,
`mai` tinyint(1) DEFAULT NULL,
`jun` tinyint(1) DEFAULT NULL,
`jul` tinyint(1) DEFAULT NULL,
`aou` tinyint(1) DEFAULT NULL,
`sep` tinyint(1) DEFAULT NULL,
`ocb` tinyint(1) DEFAULT NULL,
`nov` tinyint(1) DEFAULT NULL,
`dem` tinyint(1) DEFAULT NULL
);
-- Table structure for table `Preparation`
CREATE TABLE `Preparation` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL
);
-- Table structure for table `Aime`
CREATE TABLE `Aime` (
`ingredient` INTEGER DEFAULT NULL,
`humain` INTEGER DEFAULT NULL,
`niveau` tinyint(4) DEFAULT NULL,
PRIMARY KEY (ingredient, humain),
FOREIGN KEY (ingredient) REFERENCES Ingredient(id),
FOREIGN KEY (humain) REFERENCES Humain(id)
);
-- Table structure for table `Recette`
CREATE TABLE `Recette` (
id INTEGER PRIMARY KEY AUTOINCREMENT,
`nom` mediumtext DEFAULT NULL,
`tempsTotal` mediumtext DEFAULT NULL,
`genre` INTEGER DEFAULT NULL,
`unitePortion` INTEGER DEFAULT NULL,
`nbPortion` mediumtext DEFAULT NULL,
`realisation` mediumtext DEFAULT NULL,
`commentaire` mediumtext DEFAULT NULL,
FOREIGN KEY (genre) REFERENCES Genre(id),
FOREIGN KEY (unitePortion) REFERENCES Unite(id)
);
-- Table structure for table `RecetteIngredient`
CREATE TABLE `RecetteIngredient` (
`ingredient` INTEGER NOT NULL,
`recette` INTEGER NOT NULL,
`quantite` mediumtext DEFAULT NULL,
`unite` INTEGER DEFAULT NULL,
PRIMARY KEY (`ingredient`, `recette`),
FOREIGN KEY (ingredient) REFERENCES Ingredient(id),
FOREIGN KEY (recette) REFERENCES Recette(id),
FOREIGN KEY (unite) REFERENCES Unite(id)
);
-- Table structure for table `RecettePreparation`
CREATE TABLE `RecettePreparation` (
`preparation` INTEGER NOT NULL,
`recette` INTEGER NOT NULL,
`duree` INTEGER DEFAULT NULL,
`temperature` mediumtext DEFAULT NULL,
PRIMARY KEY (`preparation`,`recette`),
FOREIGN KEY (preparation) REFERENCES Preparation(id),
FOREIGN KEY (recette) REFERENCES Recette(id)
);
-- Table structure for table `RecetteUstensile`
CREATE TABLE `RecetteUstensile` (
`ustensile` INTEGER NOT NULL,
`recette` INTEGER NOT NULL,
`commentaire` mediumtext DEFAULT NULL,
PRIMARY KEY (`ustensile`,`recette`),
FOREIGN KEY (ustensile) REFERENCES Ustensile(id),
FOREIGN KEY (recette) REFERENCES Recette(id)
);
-- Table structure for table `Reutilise`
CREATE TABLE `Reutilise` (
`utilisee` INTEGER NOT NULL,
`utilisant` INTEGER NOT NULL,
`quantite` mediumtext DEFAULT NULL,
PRIMARY KEY (`utilisee`,`utilisant`),
FOREIGN KEY (utilisee) REFERENCES Recette(id),
FOREIGN KEY (utilisant) REFERENCES Recette(id)
);