DBMS Lab
DBMS Lab
LAB ASSIGNMENT
2)Assignment:
Create the pizza database by running the pizza.sql file.
Steps: 1) create database with name ‘pizza’ -> CREATE database pizza;
2) mysql -u root -p pizza < your sql file path
Problems:
3. List the name and age of all the people who eat sausage pizza
4. Find the names and gender of all people who eat mushroom pizza.
5.
a. Find all pizzerias frequented by at least one person under the age of 18
b. Find the names of all females who eat either mushroom or pepperoni pizza (or
both)
c. Find the names of all females who eat both mushroom and pepperoni pizza
d. Find all pizzerias that serve at least one pizza that Amy eats for less than
$10.00
e. Find all pizzerias that are frequented by only females or only males
f. For each person, find all pizzas the person eats that are not served by any
pizzeria the person frequents. Return all such person (name) / pizza pairs
g. Find the names of all people who frequent only pizzerias serving at least one
pizza they eat
h. Find the names of all people who frequent every pizzeria serving at least one
pizza they eat
i. Find the pizzeria serving the cheapest pepperoni pizza. In the case of ties,
return all of the cheapest-pepperoni pizzerias.
3)Consider a schema with two relations, R(A, B) and S(B, C), where all values are
integers. Make no assumptions about keys. Consider the following three relational
algebra expressions:
Two of the three expressions are equivalent (i.e., produce the same answer on all
databases), while one of them can produce a different answer. Which query can
produce a different answer? Give the simplest database instance you can think of
where a different answer is produced
4) Assume you have two relations R and S, where R contains N tuples and S contains
M tuples, and N > M (i.e., R has more rows). For each expression below, give the
minimum and maximum number of tuples possible for the resulting relation.
(a) R ∪ S
(b) R ∩ S
(c) R − S
(d) R/S
(e) σ(x=10)R
(f) R × S
5) Consider a relation Temp(regionID, name, high, low) that records historical high and
low temperatures for various regions. Regions have names, but they are identified by
regionID, which is a key. Consider the following query, which uses the linear notation
introduced at the end of the relational algebra videos.
State in English what is computed as the final Result. The answer can be articulated in
a single phrase.
TO-DO:
a) Create the above tables by properly specifying the primary keys and foreign
keys.
d) List the orderno for orders that were shipped from all the warehouses that the
company has in a specific city.
e) Demonstrate the deletion of an item from the ITEM table and demonstrate a
method of handling the rows in the ORDER_ITEM table that contains this particular
item.