DBMS Assignment_5
DBMS Assignment_5
(22CS104)
Name : Karanraj
Ht no : 2203A51241
Batch : 07
Note: Build the schemas for the above description of the restaurant reservation system following all
the key constraints and referential integrity constraints.
2. Consider the following schemas:(10 Marks)
Command : create table Bouquets_1241(B_ID int PRIMARY KEY ,B_name VARCHAR(10), B_description
VARCHAR(10),B_price int);
Customers(Customer ID, name, phone, and valid email)
Orders(Unique ID, customer ID, bouquet ID, address ID, delivery date, and status)
Command : create table Orders_1241(F_ID int PRIMARY KEY, C_ID NUMBER(5),B_ID NUMBER(5),A_ID
NUMBER(5),O_DELIVERYdate DATE,O_status VARCHAR(10),FOREIGN KEY(F_ID) REFERENCES
FLOWERS_1241(F_ID),FOREIGN KEY(B_ID) REFERENCES Bouquets_1241(B_ID),FOREIGN KEY(C_ID)
REFERENCES Customers_1241(C_ID));
Delivery Addresses(Unique ID, customer ID, street, city, state, and postal code)
Command : create table Delivery_1241(D_ID int, C_ID NUMBER(5), D_street VARCHAR(15),D_city
VARCHAR(15),D_state VARCHAR(15),D_postalcode NUMBER(10),FOREIGN KEY(C_ID) REFERENCES
Customers_1241(C_ID));
Queries:
1. Find the names of the flowers having name starting with ‘r’ and having maximum length
of four characters.
Command : select F_NAME FROM Flowers_1241 where F_NAME like 'R%' and
length(f_name)<=4;
2. Find all the names of the flowers whose order status is ‘pending’;
Command : select f_name from flowers_1241 fl,orders_1241 ord where fl.f_id=ord.f_id and
ord.o_status='PENDING';
3. Find the average price of bouquets ordered by customers from a specific city.
Command : select avg(b.b_price) from bouquets_1241 b,delivery_1241 d,orders_1241 o
where d.f_id=o.f_id and o.b_id=b.b_id and d.d_city='adilabad';
4. Find all the names of the customers who didn’t order on a particular date.
6. Retrieve all delivery addresses with a postal code starting with '90':
Command :
Select o.a_id from orders_1241 o,delivery_1214 d where d_postalcode like ‘90%’ and
o.f_id=d.f_id;
8. Find the maximum orders placed by the customers for a particular bouquet id.
9. Find the orders details whose delivery date is after ‘21-feb-2024’ and delivery status as
‘pending’.
*NOTE : No any orders in pending after deliverydate 21-FEB-2024 in my dataset;
Command : select * from orders_1241 o,delivery_1241 d where d.d_deliverydate>’21-FEB-
2024’ and o.o_status=’PENDING’ and o.c_id=d.c_id;
10. Find the id’s of customers who ordered white color and red color flowers.
By: Karanraj