0% found this document useful (0 votes)
2 views

TP2_sql

The document outlines the creation of several database tables including 'client', 'product', 'oorder', 'cart', 'oorderline', 'payment', and 'card', along with their respective fields and constraints. It also includes modifications to existing tables, such as adding new columns and constraints for data validation. Additionally, there are commands to describe the structure of each table.

Uploaded by

Yahya Habachi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

TP2_sql

The document outlines the creation of several database tables including 'client', 'product', 'oorder', 'cart', 'oorderline', 'payment', and 'card', along with their respective fields and constraints. It also includes modifications to existing tables, such as adding new columns and constraints for data validation. Additionally, there are commands to describe the structure of each table.

Uploaded by

Yahya Habachi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dorra Boucharbia 3rd class ‘A’ English

TP2 14/10/2023
create table client (

id_client char(7) primary key not null ,

name_cl char(7) not null ,

fst_name char(7) ,

adress char(7) not null ,

email char(20) check (email like ('%@%'))

);

CREATE table product (

codp char(8) not null ,

namep char(8) not null,

price number(7),

quanstk number(7) check (quanstk>0),

minstk number (7) check (minstk between 10 and 50),

constraint pk_codp primary key (codp)

create table oorder (

ordnum number(4) primary key not null,

creat_date date ,

amount number(7),

cart_id number(5)

create table cart (

id_cart number(4) primary key not null,

id_client char(7),

constraint constraint_id_client foreign key (id_client) references client (id_client)

)
create table oorderline (

idOline int primary key not null ,

codp char(8) not null ,

qty int ,

id_cart number(4),

constraint c_codp foreign key (codp) references product (codp),

constraint constraint_id_cart foreign key (id_cart) references cart (id_cart)

create table payment (

nump int primary key not null ,

datep date ,

status char(20) check (status in('accepted','rejected')) ,

id_card number(4),

ordnum number(4),

foreign key (ordnum) references oorder (ordnum),

foreign key (id_cart) references cart (id_cart)

create table card (

id_card number(7) primary key not null ,

typec varchar(20),

date_exp date

describe client ;

describe product ;

describe oorder ;

describe cart ;

describe oorderline ;

describe payment ;
describe card ;

alter table client add (login varchar(5), passwd varchar(20));

alter table product modify (namep char(25));

alter table client modify (fst_name char(25))

alter table client modify (adress char(25))

alter table client modify (email char(25))

alter table client modify (login char(25))

alter table client add constraint c_passwd1 check ( length(passwd) >10)

alter table client add constraint c_email check (email is not null)

alter table client add constraint c_login check (login is not null)

alter table client add constraint c_passwd2 check (passwd is not null)

/*select table_name from all_tables*/

You might also like