Professional Documents
Culture Documents
ANSWERS
(a) Identify the keys(Primary Key and Foreign Key)from each table.
(b) Write a query to display all software for the operating system ‘Linux’ from
the table Software.
(c) Write a Query to list all the license where cost is more than Rs.35000.
Group the output by CustomerId, and in ascending order of cost.
(d) For the License purchased after January 1, 2021 , the cost has been
increased by 10% . Write a query to achieve this.
(e) Write a Query to add a column category in the table customer so that it
should be able to store one of these categories (‘Domestic’, ‘International’,
‘government’, ‘Military’)
Answers
(a)
Table Primary Key Foreign Key
CUSTOMER CustomerId None
SOFTWARE SoftwareId None
LICENSE LicenseId CustomerId(with table Customer)
SoftwareId(with table Software)
(a) Identify the attribute best attribute best suitable for a Primary Key.
(b) Write the cardinality and Degree of the table.
(c) Insert the following data into attributes ItemNO, ItemName and Scode respectively in
the given table
ItemNo=2010, ItemName= ‘Note book’ , and Scode=25
(d) Which command can be used to remove the table Store from the Database
Permanently?
(e) Write a Query to display the structure of the table STORE.
ANSWERS
(a) ItemNo
(b) Degree=4, Cardinality=7.
(c) Insert into Store (ItemNo, ItemName,Scode) Values(2010, “Note Book”, 25);
(d) Drop table Store;
(e) Describe Store;
ANSWERS
I.
Count(Distinct(Department))
6
II.
Max(AGE)
65
III.
AVG(Charges)
400
IV.
Sum(Charges)
1300
(a) Display the names of the students who have grade ‘C’ in either Game1 or Game2
or both.
(b) Display the number of students getting grade ‘A’ in Cricket.
(c) Display the names of the students who have same game for both Game1 and
Game2.
(d) Display the games taken up by the students , whose name starts with ‘A’.
(e) Add a new column named ‘ Marks’.
(f) Assign a value 200 for marks for all those who are getting grade ‘B’ or grade ‘ A’ in
both Game1 and Game2.
(g) Arrange the whole table in the alphabetical order of Name.
8- Given the following Teacher relation : Write SQL command for the
questions :