Sample Paper Questions on Database Management System
Sample Paper Questions on Database Management System
1. Explain with example any two commands each of DDL and DML.
A. DDL commands
CREATE: It is used to create an object like table in database.
DROP: It is used to delete database objects.
DML commands
SELECT: It is used to retrieve data from the database Table.
INSERT INTO: It is used to insert a line of new data fields into a Table.
2. Explain the term “Referential Integrity”. Why is it important in a database?
A. Referential Integrity is used to maintain the accuracy and consistency of data in a relationship. In
Base, data can be linked between two or more tables with the help of primary key and foreign
key constrains.
Referential Integrity is important in DBMS as:
• It prevents the entry of duplicate data.
• It prevents one table from pointing to a nonexistent field in another table.
• It prevents consistency between “Partnered” tables.
• It prevents the deletion of a record that contains a value referred to by a foreign key in another
table.
• It prevents the addition of a record to a table that contains a foreign key unless key unless there
is primary key in the linked table.
3. Consider the following Vendor table and write the queries for the following:
Table: DateSheet
i) Write a SQL command to display the records in ascending order by date of exam.
ii) Write a query to display the above date sheet.
iii) Write a query to display the subject name and date of the exam held on ‘Monday’
iv) Write a SQL command to display the date of exam and Sub_Name of Science Subject.
A. i) Select*from Datesheet order by DateofExam
ii) Select*from Datesheet
iii) Select Sub_Name, DateofExam from Datesheet where Days= ‘Monday’
iv) Select Sub_Name, Date of Exam from Datesheet where Sub_Name = ‘Science’
4. Consider the following table: Employee
Employee Table
Emp_id Name Salary Designation
E01 Kajal 78000 Manager
E02 Rahul 50000 Sales Executive
E03 Tarun 55000 Clerk
(a) You are tasked with designing a new employee database for your company. Based on the
given table structure, identify the fields that would be necessary to store key information about
each employee.
(b) As a database administrator, you need to ensure each employee has a unique identifier.
Which field in the table would you choose as the primary key, and why?
(c) During a review of the employee database, you realize there could be another field apart from
the primary key that can uniquely identify a record. Identify the field and justify why it could
serve as an alternate key.
(d) You are integrating the employee table with another table that stores department details.
Explain how you would use the primary key from the employee table & a foreign key in the
department table to establish a relationship between the two tables.
Illustrate with an example.
A. a. Emp_id, Name,Salary, Designation
b. Emp_id
c. Combination of Emp_id and Name
d. Primary Key: Unique identifier for each row in a table, cannot be NULL.
Example:
Emp_id in Employees.
Foreign Key: Links to a primary key in another table, establishing relationships.
Example:
Emp_id in Orders referencing Emp_id in Employees
5. Consider the following table: Sales
i. Display the total amount of each item. The amount must be calculated as the price multiplied
by quantity for each item.
ii. Display the details of items whose price is less than 50.
A. a. Itemno integer 10
Iname varchar 15
Price decimal 5,2
Quantity integer 3
b. i. Select price * quantity from item;
ii. Select * from item where price < 50;
10. (a) Write a Query to create a Table with the following structure
Table: Product
Field Datatype
PID Char(4)
Pname Varchar(20)
Description Varchar(40)
Price Decimal
(b) Consider the following Vendor table and write the queries
Table: Vendor
VendorID VName DateofRegistration Location
V001 Mother Diary 20-01-2009 Delhi
V002 Havmor 01-04-2015 Gujarat
V003 Amul 12-05-2012 Kolkata
V004 Kwality Walls 15-10-2013 Mumbai
i. Write a Query to display all records
ii. Write a Query to add a new row with the following details
(„V005‟, „Vadilal‟, „2010-03-20‟, „Pune‟)
iii. Write a query to modify the location of V003 from Kolkata to Gujrat
A. (a) Create table Product (PID Char(4), Pname Varchar(20), Description Varchar(40), Price
Decimal);
(b) (i) Select * from Vendor;
(ii) Insert into Vendor values („V005‟, „Vadilal‟, „2010-03-20‟, „Pune‟);
(iii) Update Vendor Set location= „Gujrat‟ Where location= „Kolkata‟;
11. Write command to create a table named ‘BOOK’ with following fields:
BOOK ID Char(4)
Bname Varchar(15)
Author Varchar(20)
Price Decimal
a. Identify the primary key of the ‘Book’ Table, also mention the suitable reason for choosing
it as a Primary Key
b. Differentiate between
(i) char and varchar datatype
(ii) DDL and DML
A. Create table BOOK (BOOK_ID char(4), Bname varchar(15), Author varchar(20), Price Decimal );
(a) Book_id may be chosen as the Primary key because every book has a unique id that may be
used to identify the book.
(i) Char and Varchar
Char Varchar
Stores exactly the length specified by It Stores up to the specified length.
user in field definition.
Pads with trailing spaces for shorter No padding with extra spaces.
strings.
12. Write the SQL Commands to answer the queries based on Fabric Table