0% found this document useful (0 votes)
17 views4 pages

tp4 SQL

The document outlines a database schema and operations for an e-commerce system, including tables for clients, products, orders, carts, order lines, payments, remarks, and categories. It contains SQL commands for inserting, updating, and deleting data, along with creating relationships between tables. Additionally, it includes queries for retrieving and analyzing data from the database.

Uploaded by

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

tp4 SQL

The document outlines a database schema and operations for an e-commerce system, including tables for clients, products, orders, carts, order lines, payments, remarks, and categories. It contains SQL commands for inserting, updating, and deleting data, along with creating relationships between tables. Additionally, it includes queries for retrieving and analyzing data from the database.

Uploaded by

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

Tp2

Dorra boucharbia 3rd yr ing info


describe client
describe product
describe oorder
describe cart
describe oorderline
describe payment

insert into oorder (ordnum,creat_date,amount,cart_id) values(1,date'2023-


10-22',250.50,1)

insert into oorder (ordnum,creat_date,amount,cart_id) values(2,date'2023-


10-23',150.75,2)

insert into oorder (ordnum,creat_date,amount,cart_id) values(3,date'2023-


10-24',175.99,3)

insert into oorder (ordnum,creat_date,amount,cart_id) values(4,date'2023-


10-25',99.5,4)

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('789', 'Sami','Ben
salah' ,'sousse' ,'[email protected]','Samibensalah01','SBS01sbssss')

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('790', 'Ali', 'Ben mohamed','kairouan','ali@gmail,fr',
'Alibenmed02', 'ABM02abmaaa')

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('791', 'Moez', 'Mohamed', 'Tunis', 'moez@gmail,com','Moezmed03',
'MM03mmaaaaa')

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('792', 'Rami', 'Ben mahmoud', 'sousse', 'rami@gmail,com',
'Ramibenmah04', 'RBM04rbmaaa')

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('793', 'Hana', 'Ben Youssef', 'Djerba', '[email protected]',
'HanaYsf05', 'HBY05hby5464')

insert into client (id_client,name_cl,fst_name,adress,email,login,passwd)


values('794', 'Malak', 'Mestiri',
'Monastir','[email protected]','MalakHM06', 'MMo06mmO7777')
insert into cart (id_cart,id_client) values(1,'790')

insert into cart (id_cart,id_client) values(2,'791')

insert into cart (id_cart,id_client) values(3,'792')

insert into cart (id_cart,id_client) values(4,'793')

insert into product (codp, namep, price, quanstk, minstk)


values('100' ,'dress', 200 ,23 ,50)

insert into product (codp, namep, price, quanstk, minstk) values('101',


'skirt40', 150 ,25, 20)

insert into oorderline (idOline , codp , qty , id_cart) values(1,'100',


2,1)

insert into oorderline (idOline , codp , qty , id_cart) values(2,'101',


3,2)

insert into card (id_card ,typec,date_exp )


values(12345,'visa',date'2024-12-31')

insert into card (id_card ,typec,date_exp )


values(5431,'mastercard',date'2025-06-30')

alter table payment drop column id_cart

alter table payment add id_card number(5)

alter table payment add constraint c_hamma foreign key (id_card) references
card(id_card)

insert into payment (nump,datep,status ,id_card ,ordnum )


values(1,date'2023-10-24','accepted',12345,1)

insert into payment (nump,datep,status ,id_card ,ordnum )


values(2,date'2023-10-25','rejected',5431,2)

commit

part2 tp2
create table remarks (
remarkid number(5) primary key ,

remark varchar2(100),

id_client char(7) ,

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

insert into remarks (remarkid,remark,id_client) values(1,'excellent','790')

insert into remarks (remarkid,remark,id_client) values(2,'problem','791')

delete from remarks where id_client = '790'

update remarks set remark = 'solved' where id_client ='791'

part3
create table category (

category_id number(5) primary key,

categorylabel varchar2(50)

alter table product add (categoryid number(5))

ALTER TABLE product ADD CONSTRAINT ForeignKey_catg FOREIGN KEY (Categoryid) REFERENCES
category (category_id)

insert into category (category_id , categorylabel) values (1, 'clothes');

insert into category (category_id , categorylabel) values (2, 'electronic');

insert into category (category_id , categorylabel) values (3, 'perfumes');

insert into category (category_id , categorylabel) values (4, 'shoses');

ALTER COLUMN category_id primary key number(5) NOT NULL

update product set categoryid =1

select * from product


alter table client modify (fst_name char(25),adress char(25))

delete from category where categorylabel='perfumes'

select * from product where price > 300

select * from oorder where creat_date = '22,10,2023'

select * from product where quanstk <1

select * from product where label like %e

select * from category where categorylabel like a%s

select * from client order by name_cl desc

select * from product order by price desc

select * from oorder order by creat_date asc

select * from payment order by nump desc

select count(*) from client

select avg(price) from product

select * from product where price>(select avg(price)from product)

select sum (amount) from oorder

select avg (amount) from oorder

select sum(quantsk) from product

select * from product where price<(select min(price) from product)

You might also like