0% found this document useful (0 votes)
41 views20 pages

PROJECT Complete Queries

The document describes a Burger Ordering System project that allows users to select and order burgers, beverages, and desserts. It includes entity relationship diagrams and tables for customers, products, orders, transactions, and deliveries. Sample data is inserted into the tables.
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)
41 views20 pages

PROJECT Complete Queries

The document describes a Burger Ordering System project that allows users to select and order burgers, beverages, and desserts. It includes entity relationship diagrams and tables for customers, products, orders, transactions, and deliveries. Sample data is inserted into the tables.
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/ 20

QUEZON CITY UNIVERSITY

COLLEGE OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGY

CC105 – Information Management

Group Members
No. Student Number Student Name
1 21-1831 ASUNCION,DANICA - LEADER
2 21-1834 DURAN,MARK ANGELO TONIL
3 21-1818 SALEM,EDELYN
4 21-1830 BALDERAMA, BEVERLY

BURGER ORDERING SYSTEM

Description:
Burger Ordering System is the program that allows the users to select their orders
burger, beverage, dessert. This program is user friendly; it is easy to use and
creates orders from customers. An online food ordering system allows your
business to accept and manage orders placed online for delivery or takeaway.
Customers browse a digital menu, either on an app or website and place and pay
for their order online. Venues will then receive the order details via their chosen
online food ordering system and produce the order ready for delivery or customer
pickup.

Business Rules:
For every order, the customer must provide name and a local phone number. For
deliveries, the customer must provide name, a local phone number and address.
Shipping fee must be shouldered by customers. A customer receives a 5%
discount if they buy more than 10 products. Listing the order Information of a
customer.
ER DIAGRAM;
CUSTOMER
Column Type Length Decimal Null Description
Places Allowed?

CUSTOMER_ID CHAR 10 NO Primary key

CUSTOMER_NAME VARCHAR 50 NO Customer name


CUSTOMER_PHONE NUMBER NO Customer phone

CUSTOMER_ADDRESS VARCAHR 50 NO Customer address

PRODUCTS

Column Type Length Decimal Null Description


Places Allowed?
PRODUCT_CODE CHAR 10 NO Primary

PRODUCT_NAME VARCHAR 50 NO Product name

PRODUCT_PRICE DECIMAL 4 2 NO Product price, not


<=0
NO_OF_SOCK INT NO Not <=0

ORDER_DETAILS

Column Type Length Decimal Null Description


Places Allowed?
ORDER_NO CHAR 10 NO Primary key

PRODUCT_CODE CHAR 10 YES FOREIGN KEY to order


table (Product code)
QTY INT NO Not <= 0
TOTAL DECIMAL 6 2 NO TOTAL, (check) NOT
<= 0
ORDER_DATE DATE NO Date the order was
placed

TRANSACTIONS
Column Type Length Decimal Null Description
Places Allowed?
TRANSACTION_CODE CHAR 10 NO Transaction code
(Primary key)
CUSTOMER_ID CHAR 10 YES Foreign Key to
Customer table
(Customer id)
ORDER_NO CHAR 10 YES Foreign Key to order
details (order no)
PAYMENT CHAR 10 NO Payment must have
(GCASH, CASH)
DELIVERIES

Column Type Length Decimal Null Description


Places Allowed?
DELIVERY_ID CHAR 10 NO Primary key

TRANSACTION_COD CHAR 10 YES Foreign key to


E Transactions table
(transaction code)
CUSTOMER_ID CHAR 10 YES Foreign key to
Customer table
(Customer Id)
DELIVERY_DATE DATE 7 NO Date the delivery was
placed
TABLE CREATED;

create table customers


(
customer_id char(10) primary key,
customer_name varchar(50) not null,
customer_phone int not null,
customer_address varchar(50) not null
);

create table products


(
product_code char(10) primary key,
product_name varchar(50) not null,
product_price decimal(4,2) check(product_price > 0) not null,
no_of_stock int check(no_of_stock > 0) not null
);

create table transactions


(
transaction_code char(10) primary key,
customer_id char(10),
order_no char(10),
payment char(10) check(payment in('GCASH','CASH')) not null,
foreign key(customer_id) references customers(customer_id),
foreign key(order_no) references order_details(order_no)
);
create table order_details
(
order_no char(10) primary key,
product_code char(10),
qty int check(qty > 0) not null,
total decimal(6,2) check(total > 0) not null,
order_date date not null,
foreign key(product_code) references products(product_code)
);

create table deliveries


(
delivery_id char(10) primary key,
transaction_code char(10),
customer_id char(10),
delivery_date date not null,
foreign key(transaction_code) references transactions(transaction_code),
foreign key(customer_id) references customers(customer_id)
);
ROWS INSERTED;

insert into customers


values('CUS10011','MARK', 9546384902,'QUEZON CITY');
insert into customers
values('CUS10012','AVERY', 9847254742,'METRO MANILA');
insert into customers
values('CUS10013','HARPER', 9637245280,'MAKATI CITY');
insert into customers
values('CUS10014','CAMILA', 9997457334,'MANILA');
insert into customers
values('CUS10015','SCARLETT', 9746342423,'QUEZON CITY');
insert into customers
values('CUS10016','DANIEL', 9097524633,'CAGAYAN');
insert into customers
values('CUS10017','CARMELO', 9132157313,'BATANGAS');
insert into customers
values('CUS10018','ANGELO', 9426315312,'TAGUIG CITY');
insert into customers
values('CUS10019','SEBASTIAN', 9541273311,'BAGUIO');
insert into customers
values('CUS10020','ETHAN', 9534182621,'METRO MANILA');
insert into products
values('PDC1452', 'CHEESEBURGER', 69, 101);
insert into products
values('PDC1420', 'PANCAKE', 45, 104);
insert into products
values('PDC1792', 'FRIES', 40, 302);
insert into products
values('PDC1374', 'PIZZA', 89, 111);
insert into products
values('PDC1253', 'FRUIT SHAKE', 30, 126);
insert into products
values('PDC1421', 'FRIED CHICKEN', 55, 134);
insert into products
values('PDC1422', 'DONUTS', 60, 125);
insert into products
values('PDC1724', 'TACO', 80, 122);
insert into products
values('PDC1753', 'CORN DOG', 55, 135);
insert into products
values('PDC1346', 'ICE CREAM', 49, 132);
insert into order_details
values ('ORD01','PDC1420', 3, 135, '01-JAN-2022');
insert into order_details
values ('ORD02','PDC1346', 2, 98, '02-JAN-2022');
insert into order_details
values ('ORD03','PDC1724', 2, 160, '03-JAN-2022');
insert into order_details
values ('ORD04','PDC1422', 3, 185, '10-JAN-2022');
insert into order_details
values ('ORD05','PDC1253', 1, 30, '08-FEB-2022');
insert into order_details
values ('ORD06','PDC1374', 1, 89, '09-JAN-2022');
insert into order_details
values ('ORD07','PDC1452', 4, 276, '09-JAN-2022');
insert into order_details
values ('ORD08','PDC1422', 2, 120, '01-MAR-2022');
insert into order_details
values ('ORD09','PDC1753', 3, 165, '03-MAR-2022');
insert into order_details
values ('ORD10','PDC1452', 6, 414, '12-MAR-2022');
insert into order_details
values ('ORD01','PDC1420', 3, 135, '01-JAN-2022');
insert into order_details
values ('ORD02','PDC1346', 2, 98, '02-JAN-2022');
insert into order_details
values ('ORD03','PDC1724', 2, 160, '03-JAN-2022');
insert into order_details
values ('ORD04','PDC1422', 3, 185, '10-JAN-2022');
insert into order_details
values ('ORD05','PDC1253', 1, 30, '08-FEB-2022');
insert into order_details
values ('ORD06','PDC1374', 1, 89, '09-JAN-2022');
insert into order_details
values ('ORD07','PDC1452', 4, 276, '09-JAN-2022');
insert into order_details
values ('ORD08','PDC1422', 2, 120, '01-MAR-2022');
insert into order_details
values ('ORD09','PDC1753', 3, 165, '03-MAR-2022');
insert into order_details
values ('ORD10','PDC1452', 6, 414, '12-MAR-2022');
insert into deliveries
values('DLV1001','TRS1003','CUS10011','03-JAN-2022');
insert into deliveries
values('DLV1002','TRS1005','CUS10017','08-FEB-2022');
insert into deliveries
values('DLV1003','TRS1006','CUS10018','09-FEB-2022');
insert into deliveries
values('DLV1004','TRS1007','CUS10011','09-FEB-2022');
insert into deliveries
values('DLV1005','TRS1008','CUS10019','01-MAR-2022');
insert into deliveries
values('DLV1006','TRS1009','CUS10012','03-MAR-2022');
RECORDS
INSERTED;

ProjQuery-1. `
display the transactions from the details of the customer. The output from the transaction
and order number and ordered quantity of the customer must be performed. The output from
the transaction code must be in ascending order. The purpose of this query is to show the
transaction of the customer and show their order details.

select transactions.transaction_code, order_details.order_no,


order_details.qty

from transactions, order_details


where transactions.order_no = order_details.order_no and
order_details.order_date > '01-jan-2022'

order by (qty)
Part2
select Deliveries.delivery_id, customers.customer_name,
customers.customer_address, deliveries.delivery_date

from Deliveries, customers


where deliveries.customer_id = customers.customer_id and
deliveries.delivery_date > '01-jan-2022'

order by (delivery_date)

ProjQuery-2.
SELECT order_no ,MAX(qty) FROM Order_details
WHERE qty = 2
GROUP BY order_no
HAVING MAX(qty) = 2
ORDER BY MAX(qty) ASC;

Part 2.

SELECT product_name ,MAX(no_of_stock) FROM products


WHERE no_of_stock > 100
GROUP BY product_name
HAVING MAX(no_of_stock) > 100
ORDER BY MAX(no_of_stock) ASC;
ProjQuery-3.

UPDATE customers
SET customer_name = 'BEVERLY'
WHERE customer_id IN
(
SELECT customer_id
FROM customers
WHERE customer_name = 'HARPER'
)

Part 2:

UPDATE products
SET no_of_stock = 1300
WHERE product_code IN
(
SELECT product_code
FROM products
WHERE product_name = 'PIZZA'
)
ProjQuery-4.

insert into order_details


values
(
'ORD21', (select product_code from products where product_name= 'PIZZA'), 2, 178 , '16-
JAN-01'
);

Part 2.

insert into transactions


values
(
'TRS2001', (select customer_id from customers where customer_name= 'BEVERLY'), (select
order_no from order_details where order_no = 'ORD21'), 'GCASH'
);

ProjQuery-5.
select deliveries.delivery_id, customers.customer_address as "Delivery Address" from
deliveries
join customers on(deliveries.customer_id = customers.customer_id)
where delivery_date > '01-FEB-22'

Part 2.

select order_no, products.product_name as "Product" from order_details


join products on(order_details.product_code = products.product_code)
where qty = 1

ProjQuery-6.

SELECT UPPER(customers.customer_name) AS "NAME",


customer_address AS "ADDRESS",
products.product_name as "ORDER"
FROM products, customers, transactions
WHERE transactions.transaction_code = 'TRS2001' and customers.customer_name =
'BEVERLY' and products.product_code = 'PDC1452'
Part2:

SELECT transaction_code AS "Transaction No.",


customers.customer_name AS "Name",
customers.customer_address AS "ADDRESS",
products.product_name as "ORDER"
FROM products, customers, transactions, order_details
WHERE transactions.transaction_code = 'TRS1004' and customers.customer_id =
transactions.customer_id and order_details.order_no = transactions.order_no and
products.product_code = order_details.product_code

ProjQuery-7.

create view receipt as


select
transactions.transaction_code, customers.customer_name, order_details.order_no,
products.product_name as "Orders"
from transactions
join customers on(transactions.customer_id = customers.customer_id)
join order_details on(transactions.order_no = order_details.order_no)
join products on(order_details.product_code = products.product_code)
where transactions.transaction_code = 'TRS1007';
select * from receipt

Part 2:

create view loyal_customers


(Customer_ID, Customer_Name, Customer_Phone, Customer_Address)
as select customer_id, customer_name, customer_phone, customer_address from customers

where customer_name = 'BEVERLY' with read only;

select * from loyal_customers

You might also like