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

Lab 7

The document describes a bakery database with tables for customers, products, receipts, and item lists. It provides the structure of each table and asks a series of questions to write SQL queries using subqueries, joins, set operations and views on the bakery database tables.

Uploaded by

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

Lab 7

The document describes a bakery database with tables for customers, products, receipts, and item lists. It provides the structure of each table and asks a series of questions to write SQL queries using subqueries, joins, set operations and views on the bakery database tables.

Uploaded by

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

Experiment No :07

Aim : to perform joins and view operation on following data base.


Objective : to create view based on table(s) or view(s) and observe its behavior
while performing update operations on it.
Bakery dataset
The dataset contains information about one month worth of sales information for a
small bakery shop. The sales are made to known customers. The dataset contains
Information about the customers, the assortments of baked goods offered for sale
and the purchases made.
The dataset consists of the following relations:
- customers : information about the bakery's customers
- products : information about the baked goods offered for sale by the bakery
- item_list : itemized receipt information for purchases
- receipts : general receipt information for purchases

Receipts stores information about individual receipts (purchases by customers).


Each purchase may contain from one to five items, regardless of whether any items
purchased are of the same kind (e.g., two "chocolate cakes" will be billed as two
separate items on the receipt). item_list contains itemized receipt information.
Individual relations have the following description.
Customers
Id: unique identifier of the customer
LastName: last name of the customer
FirstName: first name of the customer
Products
Id : unique identifier of the baked product
Flavor: flavor/type of the product (e.g., "chocolate", "lemon")
Food: category of the product (e.g., "cake", "tart")
Price: price (in dollars)
Item_list
Receipt : receipt number (see reciepts.RecieptNumber)
Ordinal : position of the purchased item on the receipts. (i.e., first purchased
item,second purchased item, etc...)
Item : identifier of the item purchased (see product.Id)

Receipts
ReceiptNumber : unique identifier of the receipt
Date : date of the purchase. The date is in DD-MM-YYY format,
CustomerId : id of the customer (see customers.Id)
Summary of Bakery database:
CUSTOMERS (cid , fname, lname)
PRODUCTS (pid, flavor, food, price)
RECEIPTS (rno, rdate, cid)
ITEM_LIST (rno, ordinal, item)
● Understand the database.
● Draw schema diagram for Bakery database.
● Create relations with appropriate data types and integrity constraints.
● Populate the database values using the Bakery.sql file.
Exercise :
Write the following using Sub-query:
1. Display the food details that is not purchased by any of customers.
2. Show the customer details who had placed more than 2 orders on the same date.
3. Display the products details that has been ordered maximum by the customers.
(use ALL)
4. Show the number of receipts that contain the product whose price is more than
the average price of its food type.
Write the following using JOIN: (Use sub-query if required)
5. Display the customer details along with receipt number and date for the receipts
that are dated on the last day of the receipt month.
6. Display the receipt number(s) and its total price for the receipt(s) that contain
Twist as one among five items. Include only the receipts with total price more than
$25.
7. Display the details (customer details, receipt number, item) for the product that
was purchased by the least number of customers.
8. Display the customer details along with the receipt number who ordered all the
flavors of Meringue in the same receipt.
Write the following using Set Operations:
9. Display the product details of both Pie and Bear Claw.
10.Display the customers details who haven't placed any orders.
11. Display the food that has the same flavor as that of the common flavor between
the Meringue and Tart.
12. Create a view named Blue_Flavor, which display the product details (product
id, food, price) of Blueberry flavor.
13. Create a view named Cheap_Food, which display the details (product id,
flavor, food, price) of products with price lesser than $1. Ensure that, the price of
these food(s) should never rise above $1 through view.
14. Create a view called Hot_Food that show the product id and its quantity where
the same product is ordered more than once in the same receipt.
15. Create a view named Pie_Food that will display the details (customer lname,
flavor, receipt number and date, ordinal) who had ordered the Pie food with receipt
details.
16. Create a view Cheap_View from Cheap_Food that shows only the product id,
flavor and food.

Note: Read the questions carefully and then create database accordingly.

You might also like