CSE302 Mid02
CSE302 Mid02
Note: There are 6 (SIX) questions, answer ALL of them. Course Outcome (CO), Cognitive Level and Mark of
each question are mentioned at the right margin.
1. Write SQL Statements for the following queries based on the ‘Pizza’ database [CO2, C3,
schema, as given in the Appendix. Mark: 10]
a) Find the average price of each pizza type throughout all the stores. Do not
include a pizza type in the result when the average price of that pizza is less
than 9 dollars. The result must be sorted in the alphabetical order of pizza
type.
b) Rewrite the same query as mentioned in question 1.(a) using the concept of
the nested subquery.
c) Find the persons who have tasted all pizza types, which are in the menu list
of ‘Chicago Pizza’. You must use NOT EXISTS keyword to solve this query.
d) Find the name of the pizzeria and pizza that has the second lowest price.
e) Find pizzerias (pizza shops), of which the highest-priced pizza that they
serve is less than the average price of pizzas of the same type considering all
the pizzeria. You must use a WITH clause to solve the query.
2. Create a view named MushroomLovers that contains the name of persons who [CO1, C4,
had mushroom pizza. Mark: 4]
Now, assume that appropriate foreign key constraints are in place. Considering that
if the following SQL statement is executed, discuss and explain the outcome.
3. Consider the following authorization graph showing the users having SELECT [CO2, C4,
privilege on the previously created MushroomLovers view. Mark: 6]
Page 1 of 4
03 Dec 2020
a) If the user U3 executes the following SQL statement, what will be the
output?
SELECT grantor, grantee, grantable
from user_tab_privs
where table_name = ‘MushroomLovers’;
b) If U1 revokes privilege from U3, does U5 still have access to the view? Draw
the changed authorization graph in support of your answer.
4. Consider a MOVIE database in which data is recorded about the movie industry. [CO3, C6,
The data requirements are summarized as follows: Mark: 10]
• Each movie is identified by title and year of release. Each movie has a length
in minutes and a plot outline.
• Each movie has a production company, and one or more directors and one
or more actors appear in it. A movie may have a number of roles. Roles are
existentially dependent on Movies. Finally, each movie has zero or more
quotable quotes, each of which is spoken by a particular actor appearing in
the movie.
• Actors are identified by name and date of birth and appear in one or more
movies. Each actor has a role in the movie.
• Directors are also identified by name and date of birth and direct one or more
movies. It is possible for a director to act in a movie (including one that he
or she may also direct).
• Production companies are identified by name and each has an address. A
production company produces one or more movies.
Design an entity-relationship model (ER diagram) for the MOVIE database. Please
note that the information is not complete and you are free to make reasonable
assumptions. Write down your assumptions if you have made any with your design.
Your design must be legible and clear.
5. Assume that there are 3 entity sets: Faculty, Department, and Instructor A single [CO3, C4,
faculty has one or more departments and has one or more instructors. A department Mark: 4]
is associated under one faculty, and a department may have many instructors.
Draw the partial ER diagram in such a way so that the resulting database schema
can answer the query - “which instructor work under which faculty”.
You do not need to consider any attributes but must show mapping cardinalities of
a relationship set.
6. Reduce the following ER model into a set of relational schemas. Justify your [CO3, C3,
answer briefly. Mark: 6]
Page 2 of 4
03 Dec 2020
Please note that, in the diagram, ellipses represent simple attributes, dashed ellipse
represents derived attributes and double ellipse represents multi-valued attributes.
1 indicates ‘one’ side and N indicates ‘many’ side in a relationship set.
Page 3 of 4
03 Dec 2020
Person relation stores information related to a person. The Frequents relation keeps the information about the
membership of a person to a particular pizzeria (pizza shop). The Eats relation holds information about the
consumption of different types of pizza by all persons. The Serves relation contains information about the menu
of a particular pizzeria (pizza shop).
Page 4 of 4