United International University
Department of Computer Science and Engineering
CSE 3521 – Database Management Systems, Mid Term Exam, Summer 2021
Total Marks: 20, Time: 1 hour
Answer all the questions
1. Convert the following ER Diagram to equivalent relational schema diagram: [4]
2. Consider the following ER Diagram for a Cricket Academy:
Now solve the following query problems using MySQL: [1.5+1.5+3+4]
a) Show all those test match details that were played by the team named ‘teamUIU’ and played between the year
2015 to 2021 inclusive.
b) For each player of allrounder role, show his name and calculate the total number of wickets he has taken.
“Any examinee found adopting unfair means will be expelled from the trimester / program as per UIU disciplinary rules.”
c) For each player, count the total number of his senior teammates of the same role. Do not consider players having
less than 3 senior teammates.
d) Show the player(s) details who was dismissed the maximum number of times by ‘LBW’. If multiple players have the
same maximum number of LBW records then show all of their information.
or,
Show the player(s) details who has scored maximum average runs. If multiple players have the same maximum
average runs then show all of their information.
3. Consider the following database tables:
users orders payments
id name id amount o_date user_id payment_id txn_id date time amount
1 user1 1 1500 2021-01-25 1 1567 0199 2021-01-25 [Link] 1000
2 user2 2 2000 2021-01-10 2 2345 2345 2021-01-10 [Link] 2000
3 user3 3 2500 2021-01-18 1 NULL 1567 2021-01-25 [Link] 1500
4 1000 2021-01-25 3 0199
Show the output of the following MySQL queries: [1.5+2+2.5]
a)
SELECT o_date, amount, user_id, payment_id
FROM orders
WHERE payment_id IS NOT NULL
ORDER BY o_date DESC, amount DESC
b)
SELECT [Link],
order_count.num_orders
FROM users AS u
JOIN
(
SELECT user_id AS u_id, COUNT(*) AS num_orders
FROM orders
GROUP BY user_id
) AS order_count
ON [Link]=order_count.u_id
c)
SELECT [Link]
FROM users AS u
WHERE 1 < (
SELECT COUNT(*)
FROM orders AS o
WHERE o.user_id = [Link]
)
“Any examinee found adopting unfair means will be expelled from the trimester / program as per UIU disciplinary rules.”