Dbms 7
Dbms 7
Dbms 7
TECHNOLOGY
A Database Management System Project Report
on
”E-COMMERCE MANAGEMENT SYSTEM”
Submitted By -
NIVAL B L [22BBTCD040]
K S V RAHUL [22BBTCD023]
CHADRASHEKAR Y[22BBTCD013]
CERTIFICATE
This is to certify that the Database Management System Project work entitled E-
Commerce Database Management System has been carried out by Chandrashekar
Y (22BBTCD013), K S V Rahul (22BBTCD023) and Nivas B L (22BBTCD040)
bonafide students of CMR University in partial fulfillment for the award of Bachelor of
Engineering in Computer Science and Engineering (DATA SCIENCE) during
the year 2023-2024. It is certified that all corrections/suggestions indicated for Internal
Assessment have been incorporated in the Report deposited in the departmental library.
This DBMS Project Report has been approved as it satisfies the academic requirements
in respect of project work prescribed for the said degree.
————————
Signature of Guide
Prof.Spandana.S G
Assistant Professor
HOD IT/AIML/DS
2.
Contents
1 INTRODUCTION 4
2 Pre-requisite 5
3 DESIGN/BASIC STRUCTURE 6
3.1 Functional requirement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Entity Relation Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3 Relational Database Schema . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 IMPLEMENTATION 8
4.1 Creating Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5 QUERIES 10
5.1 Basic Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2 PL/SQL function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3 Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
In this modern era of online shopping no seller wants to be left behind, moreover
due to its simplicity the shift from offline selling model to an online selling model is
witnessing a rampant growth. Therefore, as an engineer our job is to ease the path
of this transition for the seller. Amongst many things that an online site requires the
most important is a database system. Hence in this project we are planning to design a
database where small scale sellers can sell their product online.
If admin want to see what are the product purchased on the particular date
select product_id
from cart_item
where (purchased='Y' and date_added='12-dec-2018');
Function which returns total number of products which a particular seller sells
create or replace function totalProducts(sId in varchar)
return number
is
total number(2):=0;
begin
select count(*) into total
from product
where seller_id=sId;
return total;
end;
/
Function execution:
declare
c number(2);
begin
c:=totalProducts('sid102');
dbms_output.put_line('Total products is : '|| c);
end;
Procedure which returns the total quantity of product with the given ID
Procedure with exception handling
create or replace procedure prod_details(p_id in varchar)
is
quan number(2);
begin
select quantity into quan from product where product_id=p_id;
exception
when no_data_found then
dbms_output.put_line('Sorry no such product exist !!');
end;
/
5.3 Triggers
Trigger that will execute before inserting new customer to database and inserting a new
cartId to the cart items table
Function to count number of cart items:
create or replace function numCartId(cd in varchar)
return number
is
total number(2):=0;
begin
select count(*) into total
from cart_item
where cart_id=cd;
return total;
end;
Trigger
Create or replace trigger before_customer
before insert
on
customer
for each row
declare
c varchar(10);
n number(2);
begin
c:= :new.cart_id;
n:=numCartId(c);
if n>0 then
dbms_output.put_line('Sorry');
end if;
insert into cart values(c);
end;
Trigger to update the total amount of user everytime he adds something to payment table
create or replace function total_cost(cId in varchar)
return number
is
total number(2) :=0;
begin
select sum(cost) into total from product,cart_item where product.product_id=cart_item.product_id and cart_id=cId;
return total;
end;
Future Scope: