DBMS - Worksheet 1
DBMS - Worksheet 1
DBMS
Worksheet - 1
5 Marks
1. Write SQL commands for the following queries (i) to (v) based on the relation Trainer
and Course given below:
(i) Display the Trainer Name, City & Salary in descending order of their Hiredate.
(ii) To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000.
(iv) To display number of Trainers from each city.
(v) To display the Trainer ID and Name of the trainer who are not belongs to ‘Mumbai’
and ‘DELHI’
2. Write SQL queries for (i) to (v), which are based on the table: SCHOOL and ADMIN
TABLE: SCHOOL TABLE: ADMIN
3.
Identify the primary key in the table. Write query for the following
ii. Find average salary in the table.
iii. Display number of records for each individual designation.
iv. Display number of records along with sum of salaries for each individual designation
where number of records are more than 1.
v. What is the degree and cardinality of the relation Employee?
4. Write SQL commands for the following queries (i) to (v) on the basis of relation Mobile
Master and Mobile Stock.
i) To display details of all the items in the Store table in descending order of LastBuy.
ii) To display Itemno and item name of those items from store table whose rate is more
than 15 rupees.
iii) To display the details of those items whose supplier code is 22 or Quantity in store is
more than 110 from the table Store.
iv) To display minimum rate of items for each Supplier individually as per Scode from
the table Store.
6. Write SQL commands for the following queries (i) to (v) based on the relations
TRAINER & COURSE given below:
(i) Display all details of Trainers who are living in city CHENNAI.
(ii) Display the Trainer Name, City & Salary in descending order of their Hiredate.
(iii) Count & Display the number of Trainers in each city.
(iv) Display the Course details which have Fees more than 12000 and name ends with
‘A’. (v) Display the Trainer Name & Course Name from both tables where Course Fees is
less than 10000.
7. Write SQL commands for the queries (i) to (iii) and output for (iv) & (v) based on a
table COMPANY and CUSTOMER .
8. Write SQL Commands for the following queries based on the relations PRODUCT and
CLIENT given below.
(i) To display the ClientName and City of all Mumbai- and Delhi-based clients in Client
table.
(ii) Increase the price of all the products in Product table by 10%.
(iii) To display the ProductName, Manufacturer, ExpiryDate of all the products that
expired on or before ‘2010-12-31’.
9. Consider the following tables Sender and Recipient. Write SQL commands for the
statements (a) to (c) and give the outputs for SQL queries (d) to (e).
TABLE; ISSUED
TABLE: DEALER
13. Anmol maintains that database of Medicines for his pharmacy using SQL to store
the data. The structure of the table PHARMA for the purpose is as follows :
Name of the table – PHARMA
The attributes of PHARMA are as follows :
MID - numeric
DBMS Worksheet – 1 - 5 Marks Page 8
MNAME - character of size 20
PRICE - numeric
UNITS - numeric
EXPIRY - date
Table : PHARMA
Write the SQL command which Anmol should execute to perform the required
task.
(d) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table
PHARMA. Which of the following commands will he use for the purpose ?
(i) UPDATE (ii) DROP TABLE
(iii) CREATE TABLE (iv) ALTER TABLE
(e) Now Anmol wants to increase the PRICE of all medicines by 5. Which of the
following commands will he use for the purpose ?
(i) UPDATE SET (ii) INCREASE BY
(iii) ALTER TABLE (iv) INSERT INTO