100% found this document useful (1 vote)
813 views10 pages

Database Worksheet

This document contains 36 questions related to database management systems and SQL. The questions cover topics such as SQL commands, relational database concepts, creating and modifying database tables, and writing SQL queries to retrieve and manipulate data. Some questions ask to differentiate between concepts, write outputs for sample SQL queries, or suggest the appropriate SQL commands to perform database operations.

Uploaded by

SAI PRASHANTH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (1 vote)
813 views10 pages

Database Worksheet

This document contains 36 questions related to database management systems and SQL. The questions cover topics such as SQL commands, relational database concepts, creating and modifying database tables, and writing SQL queries to retrieve and manipulate data. Some questions ask to differentiate between concepts, write outputs for sample SQL queries, or suggest the appropriate SQL commands to perform database operations.

Uploaded by

SAI PRASHANTH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

VELAMMAL NEW GEN SCHOOL, SHOLINGANALLUR.

XII – COMPUTER SCIENCE (083)


DATABASE MANAGEMENT
1. Which key word is used to sort the records of a table in descending order?
2. Which clause is used to sort the records of a table?
3. Which command is used to modify the records of the table?
4. Which clause is used to remove the duplicating rows of the table?
5. Differentiate between Primary key and Candidate key.
6. Differentiate between Degree and Cardinality.
7. In SQL, name the clause that is used to display the tuples in ascending order
of an attribute.
8. In SQL, what is the use of IS NULL operator?
9. Write any one aggregate function used in SQL.
10. Which of the following is a DDL command?
a) SELECT b) ALTER c) INSERT d) UPDATE
11. In SQL, write the query to display the list of tables stored in a database.
12. Which of the following types of table constraints will prevent the entry of
duplicate rows?
a) Unique b) Distinct c) Primary Key d) NULL
13. What do you understand by Candidate Keys in a table? Give a suitable
example of Candidate Keys from a table containing some meaningful data.
14. Write the full forms of DDL and DML. Write any two commands of DML in
SQL.
15. Differentiate between char(n) and varchar(n) data types with respect to
databases.
16. Which command is used to view the list of tables in a database?
17. Give one point of difference between an equi-join and a natural join.

1
18. A table, ITEM has been created in a database with the following fields:
ITEMCODE, ITEMNAME, QTY, PRICE
Give the SQL command to add a new field, DISCOUNT (of type Integer) to the
ITEM table.
19. Categorize following commands into DDL and DML commands?
INSERT INTO, DROP TABLE, ALTER TABLE, UPDATE...SET
20. Differentiate between the terms Attribute and Domain in the context of
Relational Data Model.
21. Differentiate between Candidate Key and Primary Key in the context
Relational Database Model.
22. A SQL table ITEMS contains the following columns:
TNO, INAME, QUANTITY, PRICE, DISCOUNT
Write the SQL command to remove the column DISCOUNT from the table.
23. Categorize the following SQL commands into DDL and DML:
CREATE, UPDATE, INSERT, DROP
24. Write an output for SQL queries (i) to (iii), which are based on the table:
STUDENT given below:
Table: STUDENT

(i) SELECT COUNT (*), City FROM STUDENT GROUP BY CITY HAVING
COUNT (*)>1;
(ii) SELECT MAX (DOB), MIN (DOB) FROM STUDENT;
(iii) SELECT NAME, GENDER FROM STUDENT WHERE CITY=”Delhi”;

2
25. A departmental store MyStore is considering to maintain their inventory
using SQL to store the data. As a database administer, Abhay has decided that :
• Name of the database - mystore
• Name of the table - STORE
• The attributes of STORE are as follows:
ItemNo - numeric
ItemName – character of size 20
Scode - numeric
Quantity – numeric

(a) Identify the attribute best suitable to be declared as a primary key,


(b) Write the degree and cardinality of the table STORE.
(c) Insert the following data into the attributes ItemNo, ItemName and SCode
respectively in the given table STORE.
ItemNo = 2010, ItemName = “Note Book” and Scode = 25
(d) Abhay want to remove the table STORE from the database MyStore. Which
command will he use from the following:
a) DELETE FROM store;
b) DROP TABLE store;
c) DROP DATABASE mystore;
d) DELETE store FROM mystore;
(e) Now Abhay wants to display the structure of the table STORE, i.e, name of
the attributes and their respective data types that he has used in the table.
Write the query to display the same.

3
26. Write the outputs of the SQL queries (i) to (iii) based on the relations
Teacher and Posting given below:

i. SELECT Department, count(*) FROM Teacher GROUP BY Department;


ii. SELECT Max(Date_of_Join),Min(Date_of_Join) FROM Teacher;
iii. SELECT Teacher.name,Teacher.Department, Posting.Place FROM Teachr,
Posting WHERE Teacher.Department = Posting.Department AND
Posting.Place=”Delhi”;
27. Write SQL commands for the following queries (i) to (v) based on the
relations Teacher and Posting given below:

4
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.
28. Write the output of the queries (a) to (d) based on the table, Furniture
given below:

(a) SELECT SUM(DISCOUNT) FROM FURNITURE WHERE COST>15000;


(b) SELECT MAX(DATEOFPURCHASE) FROM FURNITURE;
(c) SELECT * FROM FURNITURE WHERE DISCOUNT>5 AND FID LIKE "T%";
(d) SELECT DATEOFPURCHASE FROM FURNITURE WHERE NAME IN ("Dining
Table", "Console Table");

5
29. Consider the table, MOVIEDETAILS given below:

(a) Identify the degree and cardinality of the table.


(b) Which field should be made the primary key? Justify your answer.
OR
(a) Identify the candidate key(s) from the table MOVIEDETAILS.
(b) Consider the table SCHEDULE given below:

Which field will be considered as the foreign key if the tables MOVIEDETAILS
and SCHEDULE are related in a database?
30. Charu has to create a database named MYEARTH in MYSQL. She now needs
to create a table named CITY in the database to store the records of various
cities across the globe. The table CITY has the following structure:
Table: CITY
FIELD NAME DATA TYPE REMARKS
CITYCODE CHAR(5) Primary Key
CITYNAME CHAR(30)
SIZE INTEGER
AVGTEMP INTEGER
POLLUTIONRATE INTEGER
POPULATION INTEGER
Help her to complete the task by suggesting appropriate SQL commands.

6
31. Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT
given below:

(a) To display the average salary of all employees, department wise.


(b) To display name and respective department name of each employee whose
salary is more than 50000.
(c) To display the names of employees whose salary is not known, in
alphabetical order.
(d) To display DEPTID from the table EMPLOYEE without repetition.
32. Write output of SQL Queries (a) to (d) based on the table
VACCINATION_DATA given below:
VID NAME AGE DOSE1 DOSE2 CITY
101 Jenny 27 2021-12-25 2022-01-31 Delhi

102 Harjot 55 2021-07-14 2021-10-14 Mumbai

103 Srikanth 43 2021-04-18 2021-07-20 Delhi

104 Gazala 75 2021-07-31 NULL Kolkata

105 Shiksha 32 2022-01-01 NULL Mumbai

7
(a) SELECT Name, Age FROM VACCINATION_DATA WHERE Dose2 IS NOT NULL
AND Age > 40:
(b) SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
(c) SELECT DISTINCT City FROM VACCINATION_DATA;
(d) SELECT MAX (DOSE1), MIN(DOSE2) FROM VACCINATION DATA;
33. Write the output of SQL queries (a) and (b) based on the following two
tables DOCTOR and PATIENT belonging to the same database:
Table:Doctor
DNO DNAME FEES
D1 AMITABH 1500
D2 ANIKET 1000
D3 NIKHIL 1500
D4 ANJANA 1500
TABLE: PATIENT
PNO PNAME ADMDATE DNO
P1 NOOR 2021-12-25 D1
P2 ANNIE 2021-11-20 D2
P3 PRAKASH 2020-12-10 NULL
P4 HARMEET 2019-12-20 D1
(a) SELECT DNAME, PNAME FROM DOCTOR NATURAL JOIN PATIENT;
(b) SELECT PNAME, ADMDATE, FEES FROM PATIENT P, DOCTOR D WHERE D.
DNO = P.DNO AND FEES >1000;
34. Consider the following table PLAYER
Table: PLAYER
PNO NAME SCORE
P1 RISHABH 52
P2 HUSSAIN 45
P3 ARNOLD 23
P4 ARNAV 18
P5 GURSHARAN 42
(a) Identify and write the name of the most appropriate column from the given
table player that can be used as a Primary Key.
(b) Define the term degree in the relational data model. What is the degree of
the given table Player?

8
35. Write SQL queries for (a) to (d) based on the tables PASSENGER and FLIGHT
given below:
Table: Passenger
PNO NAME GENDER FNO
1001 Suresh MALE F101
1002 Anita FEMALE F104
1003 Harjas MALE F102
1004 Nita FEMALE F103
Table: Flight
FNO START END F_DATE FARE
F101 MUMBAI CHENNAI 2021-12-25 4500
F102 MUMBAI BENGALURU 2021-11-20 4000
F103 DELHI CHENNAI 2021-12-10 5500
F104 KOLKATA MUMBAI 2021-12-20 4500
F105 DELHI BENGALURU 2021-01-15 5000

(a) Write a query to change the fare to 6000 of the flight whose FNO is F104.
(b) Write a query to display the total number of MALE and FEMALE
PASSENGERS.
(c) Write a query to display the NAME, corresponding FARE and F_DATE of all
PASSENGERS who have a flight to START from DELHI.
(d) Write a query to delete the records of flights which end at Mumbai.
36. Rohan is learning to work on Relational Database Management System
(RDBMS) application. Help him to perform following tasks:
(a) To open the database named “LIBRARY”.
(b) To display the names of all the tables stored in the opened database.
(c) To display the structure of the table “BOOKS” existing in the already opened
database “LIBRARY”.

9
37. Write SQL queries for (i) to (iv), which are based on the table: STUDENT
given in the question 4(g):
Table: STUDENT

(i) To display the records from table student in alphabetical order as per the
name of the student.
(ii) To display Class, Dob and City whose marks is between 450 and 551.
(iii) To display Name, Class and total number of students who have secured
more than 450 marks, class wise
(iv) To increase marks of all students by 20 whose class is “XII”

10

You might also like