0% found this document useful (0 votes)
19 views9 pages

DBMS - Worksheet 1

The document is a DBMS worksheet for Grade 12 Computer Science, containing various SQL query exercises related to different tables such as Trainer, Course, School, Admin, Mobile Master, and others. It includes tasks like displaying, counting, updating, and deleting records based on specific conditions. The worksheet is structured into sections with multiple queries to practice SQL commands.

Uploaded by

aakashashiva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views9 pages

DBMS - Worksheet 1

The document is a DBMS worksheet for Grade 12 Computer Science, containing various SQL query exercises related to different tables such as Trainer, Course, School, Admin, Mobile Master, and others. It includes tasks like displaying, counting, updating, and deleting records based on specific conditions. The worksheet is structured into sections with multiple queries to practice SQL commands.

Uploaded by

aakashashiva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Grade: 12 Computer Science

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

i) To decrease period by 10% of the teachers of English subject.


ii) To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL and
ADMIN whose gender is male.
iii) To Display number of teachers in each subject.
iv) To display details of all teachers who have joined the school after 01/01/1999 in
descending order of experience.

DBMS Worksheet – 1 - 5 Marks Page 1


v) Delete all the entries of those teachers whose experience is less than 10 years in
SCHOOL table

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.

DBMS Worksheet – 1 - 5 Marks Page 2


(i) Display the Mobile Company, Name and Price in descending order of their
manufacturing date.
(ii) List the details of mobile whose name starts with “S” or ends with “a”.
(iii) Display the Mobile supplier & quantity of all mobiles except “MB003”.
(iv) List showing the name of mobile company having price between 3000 & 5000.
(v) Display M_Id and sum of Moble quantity in each M_Id.
5. Write SQL commands for i) to v) based on the relations given below

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.

DBMS Worksheet – 1 - 5 Marks Page 3


v) To display ItemNo, Item Name and Sname from the tables with their corresponding
matching Scode

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 .

DBMS Worksheet – 1 - 5 Marks Page 4


(i) To display those company name which are having price less than 30000.
(ii) To display the name of the companies in reverse alphabetical order.
(iii) To increase the price by 1000 for those customer whose name starts with ‘S’
(iv) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY,CUSTOMER WHERE
COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
(v) SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;

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’.

DBMS Worksheet – 1 - 5 Marks Page 5


(iv) To display C_ID, ClientName, City of all the clients (including the ones that have not
purchased a product) and their corresponding ProductName sold.
(v) To display productName, Manufacturer and ClientName of Mumbai City.

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).

a. To display the RecIC, Sendername, SenderAddress, RecName, RecAddress for every


Recipient
b. To display Recipient details in ascending order of RecName
c. To display number of Recipients from each city
d. To display the details of senders whose sender city is ‘mumbai’
e. To change the name of recipient whose recid is ’Ko05’ to’ S Rathore’.

DBMS Worksheet – 1 - 5 Marks Page 6


10. Write SQL commands for (i) to (v) on the basis of relations given below:
TABLE: BOOK

TABLE; ISSUED

(i) To show the books of FIRST PUBL. Publishers written by P. Purohit.


(ii) To display cost of all the books published for EPB.
(iii) Depreciate the price of all books of EPB publishers by 5%.
(iv) To display the BOOK_NAME and price of the books, more than 5 copies of which
have been issued.
(v) To show total cost of books of each type.

11. Consider the tables given below.


TABLE: STOCK

TABLE: DEALER

DBMS Worksheet – 1 - 5 Marks Page 7


(i) To display all the information about items containing the word “pen” in the field
Itname in the table STOCK.
(ii) List all the itname sold by Vikash Stationers.
(iii) List all the Itname and StkDate in ascending order of StkDate.
(iv) List all the Itname, Qty and Dname for all the items for the items quantity more than
40.
(v) List all the details of the items for which UnitPrc is more than 10 and <= 50.
12. Write SQL commands for the following queries (i) to (v) based on the relations
Teacher and Posting given below:

i. To show all information about the teacher of History department.


ii. To list the names of female teachers who are in Mathematics department.
iii. To list the names of all teachers with their date of joining in ascending order.
iv. To display teacher’s name, salary, age for male teachers only. v. To display name,
bonus for each teacher where bonus is 10% of salary.

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

(a) Write the degree and cardinality of the table PHARMA.


(b) Identify the attribute best suitable to be declared as a primary key.
(c) Anmol has received a new medicine to be added into his stock, but for which he
does not know the number of UNITS. So he decides to add the medicine without
its value for UNITS. The rest of the values are as follows :

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

DBMS Worksheet – 1 - 5 Marks Page 9

You might also like