Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

CREATE TABLE Serpents(serpent varchar(10) primary key, sexe varchar(1),

longueur int check (longueur >0),ecailles int check (ecailles >=0),


estVenimeux varchar(1) CHECK (estVenimeux IN('O','N')),
EnAmour varchar(10) check (EnAmour IN ('macho','timide','sincere','volage'))

);

CREATE TABLE Amours(serpAimant varchar(10) primary key,serpAime varchar(10),


force varchar(15) CHECK (force IN ('un peu','beaucoup','passionnement','a la
folie')),
FOREIGN KEY (serpAimant) REFERENCES Serpents(serpent),
FOREIGN KEY (serpAime) REFERENCES Serpents(serpent)
);

CREATE TABLE Nourritures(produit varchar(10) primary key ,calories int CHECK


(calories >=0)
);

CREATE TABLE Repas(serpent varchar(20),produit varchar(20),


quantite integer CHECK (quantite >0),
primary key (serpent,produit)
);

6-select serpent from Serpents s where not exists(select serpAimant from Amours
where serpAimant=s.serpent);
7-select serpAimant from Amours where force='pasionnement';
8- select serpAimant from Amours where force ='passionnement'or force='a la folie';

9-select serpAimant ,SerpAime from Amours A


where exists(select * from Amours where A.serpAime != serpAimant and
A.serpAimant=serpAime
and A.serpAime=serpAimant);

10-select serpAimant ,SerpAime from Amours A

1- select serpent from Serpents where estVenimeux='O';


2-select serpent from Serpents where estVenimeux ='O' and sexe='M';
3-select * from serpents where sexe='F' order by longueur desc;
4-
select sexe AVG(longueur/ecailles) from serpents group by sexe;
5-
select serpent from serpents where EnAmour IN
('macho','timide','s'incere','volage');
6-select serpAimant from Amours ;
7-
select serpent from Serpents where serpent not in (select serpAimant from Amours);

You might also like