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

PES2UG22CS533 University Fest DB Lab9

Uploaded by

Shreya M
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)
16 views6 pages

PES2UG22CS533 University Fest DB Lab9

Uploaded by

Shreya M
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

Database Management System – Student’s copy

DBMS: LAB 9
Functions, and Procedures
University Fest Management System

Objective: To learn and understand the usage of views, functions, and procedures
in SQL queries
INSTRUCTIONS
• In Lab 9, you are expected to solve only 1 task and submit.
• For this Lab, you would have to continue with the University Fest DB given to you last
week
Task 1: Five questions : Write the queries to solve them. Support each question with the
corresponding screenshot.

• Ensure that your mysql command client prompt is modified as per your SRN using the
command:
prompt YOUR_SRN>

• Note that this step is mandatory.


• As a part of the submission process, the following are to be submitted:
o A PDF document, containing all the Screenshots as suggested
▪ Name of the file: `<your SRN>_University_Fest_DB_Lab9.pdf`

Task 1:
Understand the various scenarios described in the given questions and write the corresponding SQL
queries for the same. Support your answers with the help of the screenshot.

Question 1
Every fest consists of multiple teams involved in making the fest a grand success. A single team,
called the head team, is responsible for heading the fest’s execution. Each event in a fest is
organized by an organizing team which is headed by a member of that team(called the team
head). To keep track of responsibility for an event in a fest, the management requires a method
to retrieve the ID of the team organizing the given event, the team’s name, the ID of the team
head, the name of the team head, the name of the fest in which the event is being organized,
the id of the head team for the fest, and the name of the team head of the head team. As an

Department of Computer Science and Engineering 1


Database Management System – Student’s copy

aspiring data analyst, write a procedure ‘ GetEventHeadDetails’ that takes in the id of an event
and returns the required data for that event.
Once the procedure is implemented, use the procedure to retrieve the required data for the
event with ID ‘E5’. Write the required query and attach the output screenshots.
NOTE:

➢ The output format(along with an example) is given below:


Event Team Team Team Team Fest name Head Leader of
name ID name Head Head Team ID the Head
ID name Team
Treasure T57 Revengers M300 Benjamin Atmatrisha T41 Maxwell
Hunt 2022

In this record, the event named ‘Treasure Hunt’ is organized by the team with ID ‘T57’ and the
name ‘ Revengers’. The team ‘Revengers’ is headed by Benjamin, whose ID is ‘M300’. This event
was held in the fest ‘Atmatrisha 2022’ which was headed by team ‘T41’, whose team lead was
Maxwell.

Department of Computer Science and Engineering 2


Database Management System – Student’s copy

Question 2:
For the sake of customer convenience, stall owners decided to display a list of all veg items or
non-veg items sold in their respective stalls. Help out the stall owners by implementing a
procedure ‘GetVegOrNonVegItems’ that would take as parameters the stall ID and the item
type(i.e. veg or non-veg) and return all the items belonging to the specified type sold in the
specified stall. Ensure that any invalid item types are handled appropriately.
Once the procedure is implemented, retrieve the list of :

• Non-veg items sold in the stall with ‘S1’


• Veg items sold in the stall with ID ‘S1’
To demonstrate the effectiveness of your procedure in handling invalid item types, call the
procedure for item type ‘ABC’ and stall ID ‘S1’.
Write the required queries and attach the output screenshots.
NOTE:

➢ The output should contain only one column i.e. item name
➢ The name of the column depends on the type specified in the procedure call:
o If the specified item type is ‘VEG’, name the column ‘Veg items’
o If the specified item type is ‘NON-VEG’, name the column ‘Non veg items’

Department of Computer Science and Engineering 3


Database Management System – Student’s copy

Question 3:
The university management has taken up an interest in the financial returns of fests so as to
enable them to make appropriate decisions with regard to the funds allocated for fest
conduction. They want to find the revenue that was collected from conducting events in a fest.

Department of Computer Science and Engineering 4


Database Management System – Student’s copy

Write a function ‘GetEventRevenue’ that returns the event revenue obtained in a fest, given
its ID.
NOTE:
➢ Event revenue for a fest, in the current context, can be defined as the total amount
collected from event registrations for all events held in that fest.

Question 4:

Department of Computer Science and Engineering 5


Database Management System – Student’s copy

Aside from event revenue, the university management also wants information about sales in
stalls set up for a fest. Write a function ‘GetStallSales’ that returns the stall sales of a fest, given
the fest ID.
NOTE:
➢ Stall sales for a fest are defined as the total amount earned by stalls set up in that fest
from the sale of items.

Question 5
The management wants to have a brief overview of all the fests organized in the university.
They want to have a look at data pertaining to each fest, such as its year of conduction, number
of teams involved, number of events held, number of stalls set up, number of participants,
sales from stalls, and sales from events. Create a view ‘FestOverview’ that displays the required
data along with the fest ID and name.
NOTE:

➢ The output format is given below


fest_id fest_name year num_teams num_events num_stalls num_partic stall_ Event_revenue
ipants sales

Department of Computer Science and Engineering 6

You might also like