Regroupe la documentation ainsi que les fichiers communs du projet collaborateur-EPA, notamment le docker-compose.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Collaborateur_Epa_Compose_Doc/db/init_db.sql

54 lines
2.3 KiB

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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
DROP DATABASE IF EXISTS collaborateur_epa;
CREATE DATABASE IF NOT EXISTS collaborateur_epa /*!40100 DEFAULT CHARACTER SET latin1 */;
USE collaborateur_epa;
DROP TABLE IF EXISTS agence;
CREATE TABLE IF NOT EXISTS agence(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS businessunit;
CREATE TABLE IF NOT EXISTS businessunit(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL UNIQUE,
agenceId int NOT NULL,
CONSTRAINT FK_BUSINESS_UNIT_AGENCE FOREIGN KEY (agenceId) references agence(Id),
PRIMARY KEY (Id)
);
DROP TABLE IF EXISTS collaborateur;
CREATE TABLE IF NOT EXISTS collaborateur(
Id int NOT NULL AUTO_INCREMENT,
Name varchar(100) NOT NULL,
FirstName varchar(100) NOT NULL,
BirthDate date NOT NULL,
Gender ENUM('masculin','feminin','autre') NOT NULL DEFAULT 'masculin',
Status ENUM('cadre','noncadre','alternant','stagiaire') NOT NULL DEFAULT 'noncadre',
ChildrenNumber smallint NOT NULL,
Address varchar(200) NOT NULL,
Telephone varchar(15) NOT NULL,
PersonalMail varchar(100) NOT NULL,
ApsideMail varchar(100) NOT NULL,
ResignationDate date NOT NULL,
businessunitId int NOT NUll,
ReferrerId int NOT NULL,
CONSTRAINT FK_COLLABORATEUR_BUSINESSUNIT FOREIGN KEY (businessunitId) REFERENCES businessunit(Id),
CONSTRAINT FK_COLLABORATEUR_PARRAIN FOREIGN KEY (ReferrerId) REFERENCES collaborateur(Id),
PRIMARY KEY (Id)
);
INSERT INTO agence(Id, Name) VALUES (1,'Clermont-Ferrand');
INSERT INTO businessunit(Id, Name, agenceId) VALUES (1,'Cournon',1);
INSERT INTO collaborateur(Name, FirstName, BirthDate, Gender, Status, ChildrenNumber, Address, Telephone, PersonalMail,
ApsideMail, ResignationDate, businessunitId, ReferrerId)
VALUES ('Dupont','Marie','1990-08-08','feminin','cadre',0,'adresse','tel','pmail','amail','2030-08-08',1,1);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;