You are on page 1of 5

Answer any 3 out of 5 questions (10 marks each)

Question 1
1. Create a new database with name upgraddbms. If a database of this name
alreadyexists in your MySQL server, choose some other name for this database.
2. Now create 3 tables with the following attributes and their data-types. Remember
thatattributes with underline are primary key attributes.
a. product (product_id int, name varchar(50), quantity int, price float,
sellervarchar(50))
b. customer (cust_id int, name varchar(50), address varchar(100))
c. purchase (cust_id int, product_id int, dop date). In the purchase table,
cust_id and product_id are foreign key dependencies in customer and
producttables respectively.
3. After creation of the tables, we realize that the product table must have another
attribute“unit” after quantity. Write the “alter table” command to add this attribute after
“quantity”.

Question 2
1. Add the following row to the product table (product_id int, name varchar(50),
quantity int, unit varchar(50), price float, seller varchar(50)). The values are in
thesame sequence as the attributes mentioned
a. 999, USB-C Charger, 1, pieces, 200, Electron Traders
2. Add the following row to the customer table (cust_id int, name varchar(50),
addressvarchar(100)). The values are in the same sequence as the attributes
mentioned
a. 7777, “Deep Kasturi”, “Shivaji Nagar, Mumbai”
3. Update the cust_id of the row added in the previous question from 7777 to 7788.

Question 3:
Write the following query using GROUP BY and HAVING clauses in MySQL.
From the purchase table, group all the rows according to cust_ids. Choose a cust_id if that
customer has made more than 2 purchases, and also choose the total number of purchases the
customer has done.
Question 4:
Write the following query logic in MySQL using nested subqueries and

● Using ALL clause


● NOT IN clause
● Using OUTER JOINS.

Choose all the product_ids that have never been purchased by a customer with cust_id 2222
(Choose a different cust_id, if this ID does not exist in the data you have added).

Question 5
1. Inside a new database (name it Netflix), create a collection (name it latestdata)
whose schema and data values are given in the table below:

(Insert these records using Mongo Shell)

Type Actor Country Date of Release Year of


Name Release

Movie Michel Mexico 23 December 2016 2016

Movie Gilbert Singapore 20 December 2018 2011

Movie Shane United States 16 November 2017 2009

Movie Robert United States 1 January 2020 2008

Type Show Name Country Date of Release Year of


Release

TV Show 13 Reasons Why United States 23 August 2019 2016

TV Show 20 Minutes Turkey 15 August 2017 2011

TV Show 13 Reasons Why United Kingdom 1 July 2020 2009

TV Show Elite India 1 December 2020 2008

2. Write a query to return all the data of TV shows and movies.

3. Write a query to return data about 13 Reasons Why.

4. Update the release year of the movie starring Robert from 2008 to 2020.
5. Delete the data of the movies that were released in 2020.

6. Delete the collection through the shell.

Question 6
Suppose the owner of an online clothing website wants to maintain data of its customers and
the products they buy from his website. A single customer can buy multiple products and can
return the products purchased. Insert the following data and perform the operations given
below using HBase.

a. Create a table named ‘Customer’ with two column families ‘Personal_Info’ and
‘Product_Info’. The version count for Personal_Info should be 2 and Product_Info
should be 4 and should be changed in case needed. Customer_Number is the
rowkey of the table.

b. Add the following data into the created table ‘Customer’


• 001 (rowkey)
Personal_Info:Customer_Name = ‘Sam’
Personal_Info:City = ‘Pune’
Personal_Info:Contact = 9877656789
Personal_Info:Contact = 8765421345
Product_Info:Name = ‘Jeans’
Product_Info:Size= ‘M’
Product_Info:Price = 1200

• 002 (rowkey)
Personal_Info:Customer_Name = ‘Rahul’
Personal_Infor:City = ‘Mumbai’
Personal_Info:Contact = 9844215263
Product_Info:Name = ‘T-shirt’
Product_Info:Size= ‘L’
Product_Info:Price = 800
Product_Info:Name = ‘Shirt’
Product_Info:Code= S
Product_Info:Price = 1000
Product_Info:Name = ‘Jeans’
Product_Info:Size= ‘L’
Product_Info:Price = 1200

● 003 (rowkey)
Personal_Info:Customer_Name = ‘Shalini’
Personal_Info:City = ‘Patiala’
Personal_Info:Contact = 8765423456
Product_Info:Name = ‘Dress’
Product_Info:Size = ‘S’
Product_Info:Price = 2300
Product_Info:Name = ‘Tshirt’
Product_Info:Size = ‘S’
Product_Info:Price = 800

● 004 (rowkey)
Personal_Info:Customer_Name = ‘Sakshi’
Personal_Info:City = ‘Ludhiana’
Personal_Info:Contact = 6789023456
Product_Info:Name = ‘Top’
Product_Info:Size = ‘M’
Product_Info:Price = 1300
Product_Info:Name = ‘T-shirt’
Product_Info:Size = ‘M’
Product_Info:Price = 800
Product_Info:Name = ‘Shirt’
Product_Info:Size= ‘S’
Product_Info:Price = 1000
Product_Info:Name = ‘Jeans’
Product_Info:Size= ‘S’
Product_Info:Price = 1200

• 005 (rowkey)
Personal_Info:Customer_Name = ‘Riya’
Personal_Info:City = ‘Delhi’
Personal_Info:Contact = 7785823459
Product_Info:Name = ‘Top’
Product_Info:SIze = ‘S’
Product_Info:Price = 1300

c. The customer named ‘Sam’ wants to return all the products purchased. Delete
the data associated with the customer named ‘Sam’.
d. The website owner wants to change the bandwidth of the products bought by
customers from 4 to 6. Use a Shell command to change the version to 6.
e. Riya wants to buy a pair of jeans of size ‘M’ of price 1200. Add the relevant
product information.
f. Calculate the number of customers.
g. Fetch the details of customers who have bought items with a price less than or
equal to 1000.
h. Fetch the names of all the customers from the table.
i. Fetch the details of the products sold.

You might also like