12-2324-SHW (Practiacal Work)
12-2324-SHW (Practiacal Work)
12-2324-SHW (Practiacal Work)
1. Consider the following table named “Product”, showing details of products being
sold in a grocery shop.
PCode PName UPrice Manufacturer
P01 Washing Powder 120 Surf
P02 Toothpaste 54 Colgate
P03 Soap 25 Lux
P04 Toothpaste 65 Pepsodent
P05 Soap 38 Dove
P06 Shampoo 245 Dove
Write SQL queries for the following:
a) Create the table Product with appropriate data types and constraints.
b) Identify the primary key in Product.
c) List the Product Code, Product name and price in descending order of their product name.
If PName is the same, then display the data in ascending order of price.
d) Add a new column Discount to the table Product.
e) Calculate the value of the discount in the table Product as 10 per cent of the UPrice for all
those products where the UPrice is more than 100, otherwise the discount will be 0.
f) Increase the price by 12 per cent for all the products manufactured by Dove.
g) Display the total number of products manufactured by each manufacturer.
2. Write the output(s) produced by executing the following queries on the basis of the
information given above in the table Product:
h) SELECT PName, avg(UPrice) FROM Product GROUP BY Pname;
i) SELECT DISTINCT Manufacturer FROM Product;
j) SELECT COUNT (DISTINCT PName) FROM Product;
k) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;
3.Suppose your school management has decided to conduct cricket matches between
students of Class XI and Class XII. Students of each class are asked to join any one of
the four teams – Team Titan, Team Rockers, Team Magnet and Team Hurricane.
During summer vacations, various matches will be conducted between these teams.
Help your sports teacher to do the following:
a) Create a database “Sports”.
b) Create a table “TEAM” with following considerations:
i) It should have a column TeamID for storing an integer value between 1 to 9, which refers
to unique identification of a team.
ii) Each TeamID should have its associated name (TeamName), which should be a string of
length not less than 10 characters.
c) Using table level constraint, make TeamID as the primary key.
d) Show the structure of the table TEAM using a SQL statement.
e) As per the preferences of the students four teams were formed as given below. Insert these
four rows inTEAM table:
Row 1: (1, Team Titan)
Row 2: (2, Team Rockers)
Row 3: (3, Team Magnet)
Row 3: (4, Team Hurricane)
f) Show the contents of the table TEAM using a DML statement.
g) Now create another table MATCH_DETAILS and insert data as shown below. Choose
appropriate data types and constraints for each attribute.
4. Using the sports database containing two relations (TEAM, MATCH_DETAILS) and write
the queries for the
following:
a) Display the MatchID of all those matches where both the teams have scored more than 70.
b) Display the MatchID of all those matches where FirstTeam has scored less than 70 but
SecondTeam has scored more than 70.
c) Display the MatchID and date of matches played by Team 1 and won by it.
d) Display the MatchID of matches played by Team 2 and not won by it.
e) Change the name of the relation TEAM to T_DATA. Also change the attributes TeamID and
TeamName to T_ID and T_NAME respectively.
5.
6 For the above given database STUDENT-PROJECT, can we perform the following
operations?
a) Insert a student record with missing roll number value.
b) Insert a student record with missing registration number value.
c) Insert a project detail without submission-date.
d) Insert a record with registration ID IP-101-19 and ProjectNo 206 in table PROJECT-
ASSIGNED.
7.Write the output for SQL queries (i) to (iii), which are based on the table:Employees
9. Write SQL commands for (a) to (e) on the basis of table INTERIORS and NEWONES.
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Red rose Double bed 23/02/02 32000 15
2 Soft touch Baby cot 20/01/02 9000 10
3 Jerry’s home Baby cot 19/02/02 8500 10
4 Rough wood Office Table 01/01/02 20000 20
5 Comfort zone Double bed 12/01/02 15000 20
6 Jerry look Baby cot 24/02/02 7000 19
7 Lion king Office Table 20/02/02 16000 20
8 Royal tiger Sofa 22/02/02 30000 25
9 Park sitting Sofa 13/12/01 9000 15
INTERIOR
10. Write SQL commands for (a) to (e) on the basis of table FURNITURE AND ARRIVAL.
NO. ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 White lotus Double Bed 23/02/02 30000 25
2 Pink feather Baby cot 20//01/02 7000 20
3 Dolphin Baby cot 19/02/02 9500 20
4 Decent Office Table 01/01/02 25000 30
5 Comfort Zone Double Bed 12/01/02 25000 25
6 Donald Baby cot 24/02/02 6500 15
7 Royal Finish Office Table 20/02/02 18000 30
8 Royal tiger Sofa 22/02/02 31000 30
9 Econo sitting Sofa 13/12/01 9500 25
10 Eating Dining Table 19/02/02 11500 25
paradise
FURNITURE
ARRIVAL
11. Write a function(s) to show working of Create , Insert , Update and Alter
command.(Connectivity with SQL ).Program is user defined.