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

DBMS Assignment_5

Uploaded by

karan20067852
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

DBMS Assignment_5

Uploaded by

karan20067852
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

3DATABASE MANAGEMENT SYSTEMS

(22CS104)
Name : Karanraj
Ht no : 2203A51241
Batch : 07

1. Build a database schema for restaurant reservation system.(10 Marks)


When building a database schema for a restaurant booking system there are a few things you must
consider.
customers make reservations for tables and those tables have orders associated with them.
An order will have associated menu items that belong to a menu.
The orders are served by a waiter.
The first step is to identify the entities involved in the this database.
The first entity “table” in the restaurant. It has a unique ID and a location – where it’s placed in the
restaurant.
The second entity is the “waiter”. They have a unique ID, a name, their contact number and which
shift they usually work.
The third entity is “orders” for each table. It has the order ID and table ID fields. As well as a
date_time field to capture the date and time of the order and the ID of the waiter who’s supposed to
serve that table, for that order.
The fourth entity is the “customer”.It has a customer ID, name, NIC number to store the National
Identity Card number and the contact number fields.
The fifth entity is the “reservation” that associates an order with a customer.It has a unique ID, a date
and time, the order_id, table_id and the customer_id.
The sixth entity is the “menu” that stores all the menus of the restaurant. It has a menu_id which is
the unique field that contains descriptions of the menu and its availability.
The seventh entity is the “menu-items”.Every menu can have unique menu items and these menu
items are stored against the menu, in the menu_item table. A menu items also has description, price
and availability fields.
The final entity is the “order_menu_item” . It captures the menu items ordered for a specific order. It
has the order_id, menu_item_id and the quantity ordered.

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)

Flowers(Unique ID, name, color, and price)

Command : create table Flowers_1241(F_ID int PRIMARY KEY, F_NAME VARCHAR(10),F_color


VARCHAR(10),F_price int);

Bouquets( bouquet ID, name, description, and price)

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)

Command : create table Customers_1241(C_ID int PRIMARY KEY, C_name VARCHAR(10),C_phone


NUMBER(10),C_email VARCHAR(20));

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.

Command : select c.c_name from customers_1241 c,orders_1241 o where c.c_id=o.c_id and


o_deliverydate<>’20-FEB-2024’;

5. Find the customers who have placed maximum number of orders.


Command :

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;

7. Find the flower details that were delivered to city ‘warangal’.


Command : select * from flowers_1241 f,delivery_1241 d where d.d_city=’warangal’ and
f.f_id=d.f_id;

8. Find the maximum orders placed by the customers for a particular bouquet id.

Command : select count(c_id) from Orders_1241 where b_id=203;

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.

Command : select c.c_id from customers_1241 c, flowers_1241 f, orders_1241 o where


c.c_id=o.c_id and o.f_id=f.f_id and f.f_color in('RED','WHITE');

By: Karanraj

You might also like