Indian Institute of Technology Kharagpur Mid-Spring Semester Examination 2023-24
Indian Institute of Technology Kharagpur Mid-Spring Semester Examination 2023-24
1) Write a program in C to find the closure of an attribute from given Functional Dependencies.
[10 M]
Test case:
Input:
Relational schema: Student (sid, sname, dept, thmarks, labmarks, cgpa)
Functional Dependencies:
sid -> sname
dept -> labmarks
{thmarks, labmarks} -> cgpa
sid -> {dept, thmarks}
Output: Closure of the attribute sid, (sid)+: sid, sname, dept, thmarks, labmarks, cgpa
2) A geographical indication (GI) is a name or sign used on certain products that corresponds to a specific
geographical location or origin. (e.g., a town, region, or country). Below is the ER diagram of
geographical indication.
[13 M]
a. Using the above ER diagram, create the database, tables, and insert the values present in
q2_entries.pdf. (4 M)
b. Display the product names of those whose geographical area's serial number is divisible by 3.
Duplicate names should not be present. (1 M)
c. Display the GI_product records in each category with the maximum registration validity date
without using rank and row_number(). (2 M)
d. Display the product name, registration validity date, and number of geographical areas in
which the product is available. (2 M)
e. Display the promoters and ratings of the products they are promoting. Sort records by rating.
(1 M)
f. Display the records in the GI_products table, sorted by product name and category, both in
descending order. (1 M)
g. Display the geographical areas corresponding to the products whose promoters have India in
their name. (2 M)
3) Answer the following questions related to E-commerce database.
Users: user ID, name, city, email id, date of birth.
Product: prod ID, prod name, description, price, ratings, brand ID*.
Offer: Offer ID, offer des, Validity.
Brand: brand ID, brand name, brand type, sales rank.
Purchase: user ID*, prod ID*, order date.
Product has: prod ID*, offer ID*.
Primary keys are underlined and Foreign keys are denoted by *
[27 M]
a) Create an e-commerce database and tables for user, product, offer, brand, purchase, and
product_has. (6 M)
b) Insert at least 3 records in each table so that each of the below queries gives at least one
output record. (6 M)
c) Find the product name, offer description, and brand name where the sales rank is not equal to
1 and the rating is between 3.5 and 4.5. Do not use natural join. (2 M)
d) Find the product ID and user names of those who got 20% cashback, along with the product
name. (2 M)
e) Categorize users as age categories according to their age (young adults from 18 to 39, middle-
aged adults from 40 to 59, and old adults from 60 and above) from the user table and select
the user’s name and date of birth column together with the age category. (2 M)
f) Display the details of the products that do not have ratings in the range (3.5, 4.5) and are
purchased by users from 'Chennai'. Sort records by product name. (2 M)
g) Display the day of birth of the user, whose city is "Hyderabad." (1 M)
h) Display product records, which are purchases made a maximum number of times. (2 M)
i) Find the user’s name who bought more than one product. (1 M)
j) Print the name of the clothing brand for which the offer is available. Do not use natural join.
(2 M)
k) Display user records whose email IDs have ‘S’ or ‘s’. (1 M)
Note: Make sure you have saved the final entries in the file “roll_no_q3_queries.sql”.
-----------------------X-----------------------