forked from deoel/m-okapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmokapi.sql
142 lines (126 loc) · 4.89 KB
/
mokapi.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-- MySQL Script generated by MySQL Workbench
-- 11/29/18 15:53:52
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mokapi
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mokapi
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mokapi` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `mokapi` ;
-- -----------------------------------------------------
-- Table `mokapi`.`utilisateur`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`utilisateur` (
`id` INT NOT NULL AUTO_INCREMENT,
`nomcomplet` VARCHAR(255) NOT NULL,
`login` VARCHAR(255) NOT NULL,
`mdp` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL,
`etat` TINYINT(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
UNIQUE INDEX `login_UNIQUE` (`login` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mokapi`.`entree`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`entree` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_utilisateur` INT NOT NULL,
`nom` VARCHAR(255) NOT NULL,
`montant` DOUBLE NOT NULL,
`date_entree` DATE NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_entree_utilisateur_idx` (`id_utilisateur` ASC),
CONSTRAINT `fk_entree_utilisateur`
FOREIGN KEY (`id_utilisateur`)
REFERENCES `mokapi`.`utilisateur` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mokapi`.`categorie_sortie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`categorie_sortie` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_utilisateur` INT NOT NULL,
`nom` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_categorie_sortie_utilisateur1_idx` (`id_utilisateur` ASC),
CONSTRAINT `fk_categorie_sortie_utilisateur1`
FOREIGN KEY (`id_utilisateur`)
REFERENCES `mokapi`.`utilisateur` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mokapi`.`exercice_budgetaire`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`exercice_budgetaire` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_utilisateur` INT NOT NULL,
`date_debut` DATE NOT NULL,
`date_fin` DATE NOT NULL,
`budget_initial` DOUBLE NOT NULL,
`date_creation` DATETIME NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_exercice_budgetaire_utilisateur1_idx` (`id_utilisateur` ASC),
CONSTRAINT `fk_exercice_budgetaire_utilisateur1`
FOREIGN KEY (`id_utilisateur`)
REFERENCES `mokapi`.`utilisateur` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mokapi`.`sortie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`sortie` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_categorie_sortie` INT NOT NULL,
`id_exercice_budgetaire` INT NOT NULL,
`seuil` DOUBLE NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_sortie_categorie_sortie1_idx` (`id_categorie_sortie` ASC),
INDEX `fk_sortie_exercice_budgetaire1_idx` (`id_exercice_budgetaire` ASC),
CONSTRAINT `fk_sortie_categorie_sortie1`
FOREIGN KEY (`id_categorie_sortie`)
REFERENCES `mokapi`.`categorie_sortie` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_sortie_exercice_budgetaire1`
FOREIGN KEY (`id_exercice_budgetaire`)
REFERENCES `mokapi`.`exercice_budgetaire` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mokapi`.`action_budgetaire`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mokapi`.`action_budgetaire` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_sortie` INT NOT NULL,
`montant_utilise` DOUBLE NOT NULL,
`motif` VARCHAR(255) NOT NULL,
`date_creation` DATETIME NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_action_budgetaire_sortie1_idx` (`id_sortie` ASC),
CONSTRAINT `fk_action_budgetaire_sortie1`
FOREIGN KEY (`id_sortie`)
REFERENCES `mokapi`.`sortie` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;