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
|
create table if not exists Branche_Direction (
IdBranche INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
NomBranche VARCHAR(50)
);
create table if not exists Secteur (
IdSecteur INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
NomSecteur VARCHAR(50),
IdBranche INT NOT NULL,
INDEX FK_secteurindex ( IdBranche ),
FOREIGN KEY (IdBranche) REFERENCES Branche_Direction(IdBranche) ON UPDATE CASCADE ON DELETE CASCADE
);
create table if not exists Categorie (
IdCategorie INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
NomCategorie VARCHAR (50)
);
create table if not exists personne (
idPersonne INT not null PRIMARY KEY AUTO_INCREMENT,
nomPersonne VARCHAR(50) not null,
prenomPersonne VARCHAR(50) not null,
login varchar(20) not null,
motDePasse varchar(41) not null,
mail varchar(60) not null,
admin char(1) not null,
idCategorie INT DEFAULT 4,
idSecteur INT DEFAULT 4,
INDEX FK_personnecategorieindex ( idcategorie ) ,
INDEX FK_personnesecteurindex ( idsecteur ) ,
FOREIGN KEY ( idCategorie ) REFERENCES Categorie(idCategorie) ON UPDATE CASCADE ON DELETE SET null,
FOREIGN KEY ( idSecteur ) REFERENCES Secteur( idSecteur ) ON UPDATE CASCADE ON DELETE SET null
);
INSERT INTO categorie VALUES (1,"Agents"),(2,"Cadres"),(3,"Direction"),(4,"aucune"); |
Partager