0% found this document useful (0 votes)
106 views6 pages

DBMS Lab

The document provides instructions for a DBMS lab assignment involving a pizza database. It includes: 1) A true/false question about query language completeness; 2) Instructions to create the pizza database from a SQL file; 3) Problems to solve using relational algebra and SQL; 4) A question about relational algebra expressions; 5) Questions about relational operators; 6) A question describing a relational algebra expression; and 7) Questions about an order processing database schema.

Uploaded by

Abhinav
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)
106 views6 pages

DBMS Lab

The document provides instructions for a DBMS lab assignment involving a pizza database. It includes: 1) A true/false question about query language completeness; 2) Instructions to create the pizza database from a SQL file; 3) Problems to solve using relational algebra and SQL; 4) A question about relational algebra expressions; 5) Questions about relational operators; 6) A question describing a relational algebra expression; and 7) Questions about an order processing database schema.

Uploaded by

Abhinav
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/ 6

DBMS

LAB ASSIGNMENT

1) True or False: if a query language is relationally complete, we are able to


express every desired query in that language. Explain your answer.

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

The file contains the table definitions and sample data.


Table Attributes Key

Person name, age, gender name

Frequents name, pizzeria (name, pizzeria)

Eats name, pizza (name, pizza)

Serves pizzeria, pizza, price (pizzeria, pizza)


For each of the following problems, write the Relational Algebra statement to solve the
problem.
After you've done that, translate it into SQL, then run the SQL code to check your work.

Problems:

1. List all the customers

2. List the name of all the pizzeria

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.

6) Consider the following relations for a order processing database application in a


company.

CUSTOMER( custno:int , cname:string , city:string )

ORDER( orderno:int , odate:date , custno:int , ord_amt:int )

ORDER_ITEM( orderno:int , itemno:int , quantity:int )

ITEM( itemno:int , unitprice:int )

SHIPMENT( orderno:int , warehouseno:int , ship_date:date )

WAREHOUSE( warehouseno:int , city:string )

TO-DO:

a) Create the above tables by properly specifying the primary keys and foreign
keys.

b) Enter at least five tuples for each relation.


c) Produce a listing: custname, No_of_orders, Avg_order_amount, where the
middle column is the total number of orders by the customer and the last column is the
average order amount for that customer.

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.

You might also like