0% found this document useful (0 votes)
31 views2 pages

Not Null : 'Casablanca' 'Rabat' 'Tanger' 'Marrakech'

The document contains SQL statements that create tables for employees, departments, projects, and employee participation in projects. Data is inserted into the tables, including employee records with salaries and department assignments. Relationships are defined between the tables using foreign keys and constraints are added to ensure data integrity.

Uploaded by

Aero Club
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
31 views2 pages

Not Null : 'Casablanca' 'Rabat' 'Tanger' 'Marrakech'

The document contains SQL statements that create tables for employees, departments, projects, and employee participation in projects. Data is inserted into the tables, including employee records with salaries and department assignments. Relationships are defined between the tables using foreign keys and constraints are added to ensure data integrity.

Uploaded by

Aero Club
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

create 

table Employe (
    Matr decimal(4) primary key,
    NomE varchar(30),
    Poste varchar(9),
    ID_SUP decimal(4),
    DateEmp DATE,
    Salaire decimal(7,2) not null check (Salaire<=50000 and Salaire>=3000),
    Commission decimal(4,2),
    NumDept decimal(2)
);

create table Departement (
    NumDept decimal(2) primary key not null,
    NomDept varchar(15) not null,
    lieu varchar(15) not null check (lieu='Casablanca' or lieu='Rabat' or lieu='Tanger' or lie
u='Marrakech')
);

alter table Employe
add foreign key(NumDept)
references Departement(NumDept)
on delete set null;
create table Projet (
    CodeP integer primary key,
    NomP varchar(100)
);
create table Participation (
    Matr decimal(4),
    CodeP integer,
    Fonction varchar(100),
    primary key(Matr,CodeP),
    foreign key(Matr) references Employe(Matr) on delete cascade,
    foreign key(CodeP) references Projet(CodeP)
);

DESC table Employe;
alter table Employe
modify column Poste varchar(30),
modify column Commission decimal(7,2);

alter table Projet
add column NbJrPrevu integer not null check (NbJrPrevu>0);

alter table Participation
add column NbJrRealise integer not null check (NbJrRealise>0);
insert into Employe VALUES(7369, 'Sanae', 'Secretaire', 7566, '1980-12-17', 4000.00, NUL
L,NULL);
insert into Employe VALUES(7499, 'Adil', 'Commercial', 7566, '1981-02-20', 11000.00, 3000.00, 
NULL);
insert into Employe VALUES(7521,'Wafae', 'Commercial', 7566, '1981-02-22', 12500.00, 5000.00, 
NULL);
insert into Employe VALUES(7566, 'Jihane', 'Directeur',7839, '1981-04-04', 19750.00, NULL, NUL
L);
insert into Employe VALUES(7654, 'Mouna', 'Commercial', 7566, '1981-09-28',12000.00, 1400.00, 
NULL);
insert into Employe VALUES(7698, 'Badr', 'Directeur', 7839, '1981-05-01', 18500.00, NULL, NUL
L);
insert into Employe VALUES(7782, 'Soufiane', 'Technicien', 7698, '1981-06-09', 6500, NULL, NUL
L);
insert into Employe VALUES(7788, 'Saad', 'Ingenieur', 7698, '1982-12-09', 20000.00, NULL, NUL
L);
insert into Employe VALUES(7839, 'Kamall', 'President', NULL, '191-11-17', 30000.00, NULL, NUL
L);
insert into Employe VALUES(7844, 'Siham', 'Commercial', 7566, '1981-09-08', 10000.00, 0.00, NU
LL);
insert into Employe VALUES(7876, 'Karim', 'Technicien', 7698, '1983-01-12', 4100.00, NUL
L,NULL);
insert into Employe VALUES(7900, 'Nabil', 'Technicien', 7698, '1981-12-03', 5000.00, NULL, NUL
L);
insert into Employe VALUES(7902, 'Ahlam', 'Ingenieur', 7698, '1981-12-03', 20000.00, NULL, NUL
L);
insert into Employe VALUES(7934, 'Manar', 'Secretaire', 7698, '1982-01-23', 4300.00, NULL, NUL
L);

insert into Departement VALUES(10, 'Administration', 'Rabat');
insert into Departement VALUES(20, 'Informatique', 'Rabat');
insert into Departement VALUES(30, 'Commercial', 'Casablanca');
insert into Departement VALUES(40, 'Production', 'Tanger');
update Employe 
set NumDept=10
where Matr=7839;

update Employe
set NumDept=20
where Matr=7782 or Matr=7788 or Matr=7876 or Matr=7900 or Matr=7902 or Matr=7934;

update Employe
set NumDept=30
where Matr=7369 or Matr=7499 or Matr=7521 or Matr=7566 or Matr=7654 or Matr=7698 or Matr=7844;

insert into Projet VALUES(1, 'E-Commerce', 15);
insert into Projet VALUES(2, 'Etude de Marche', 18);
insert into Projet VALUES(3, 'Formation Bureautique', 23);

insert into Participation VALUES(7698, 1, 'Responsable', 16);
insert into Participation VALUES(7782, 1, 'Develloppeur Web', 152);
insert into Participation VALUES(7876, 1, 'Administrateur de Base de donnees',160);
insert into Participation VALUES(7566, 2, 'Responsable', 09);
insert into Participation VALUES(7499, 2, 'Commercial', 12);
insert into Participation VALUES(7521, 2, 'Commercial', 25);
insert into Participation VALUES(7369, 2, 'Secretaire', 14);

You might also like