0% found this document useful (0 votes)
4 views1 page

TP1 SQL Restaurant

The document outlines the SQL commands for creating and modifying database tables related to a restaurant management system. It includes definitions for tables such as restaurants, plats, livreurs, commandes, clients, and lignecommande, along with their constraints and relationships. Additionally, it specifies alterations to the 'plats' and 'restaurants' tables to include new fields and constraints for availability and ratings.

Uploaded by

dhouhabensalah02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

TP1 SQL Restaurant

The document outlines the SQL commands for creating and modifying database tables related to a restaurant management system. It includes definitions for tables such as restaurants, plats, livreurs, commandes, clients, and lignecommande, along with their constraints and relationships. Additionally, it specifies alterations to the 'plats' and 'restaurants' tables to include new fields and constraints for availability and ratings.

Uploaded by

dhouhabensalah02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

--Question1

create table restaurants (idR varchar2(20) primary key, nom varchar2(20) Unique,

specialite varchar2(15), ville varchar2(15), tel number(8),


constraint R_ck1 check (specialite in ('Tunisienne', 'Française',
'Italienne','Mexicaine', 'Thailandaise', 'Japonaise')),
constraint R_ck2 check (tel >= 0 and tel<=99999999));

create table plats (ref_P int Primary key, idR varchar2(20),


nomp varchar2(20), prix number(4), freegluten int, disponible int, rating int
default 0,
constraint P_ck1 check(rating >= 0 and rating <= 5),
constraint P_ck2 check (prix >= 0 and prix <= 80),
constraint P_FK Foreign key (idR) References restaurants (idR));

create table livreurs (idl int primary key, cin Number(8) not null unique, nom
varchar2(30),
prenom varchar2(30), tel number(8), daterec date,
constraint L_ck check (cin between 00000000 and 99999999));

create table commandes (idc int primary key, idl int, idcli int, total
number(4),
datehcom timestamp, datehliv timestamp, paye integer,
constraint C_FK1 Foreign Key (idl) references livreurs (idL),
constraint C_FK2 Foreign Key (idCli) references clients (idcli));

create table clients (idcli int primary key, login varchar2(20) unique,
mdp varchar2(20), nom varchar2(30), prenom varchar2(30),
tel number(8), ville varchar2(20),
constraint Cl_ck check (tel between 00000000 and 99999999)
);

create table lignecommande (idc int, ref_P int, quantite int not null,
Constraint LC_Pk Primary Key(idc,ref_P),
constraint LC_FK1 Foreign key(idc) references commandes (idc),
constraint LC_FK2 Foreign key(ref_P) references plats (ref_P));

--Question 2

Alter table Plats Modify (disponible varchar2(3) default 'non');


Alter table Plats add constraint P_Ck3 check(disponible in ('oui','non'));

--Question 3

Alter table restaurants add (rating int default 0);


Alter table restaurants add constraint R_Ck3 check (rating >= 0 and rating <=
5);

You might also like