Multiple Choice Question [1 X 6]
1. The main purpose of a DBMS is:
a) To print reports
b) To manage data efficiently
c) To create graphics
d) To write programs
Answer: b) To manage data efficiently
2. Which of the following is a virtual table?
a) Relation
b) View
c) Attribute
d) Key
Answer: b) View
3. Which of the following is not the purpose of DBMS?
a) Data consistency
b) Reducing redundancy
c) Data visualization and charting
d) Data sharing
Answer: c) Data visualization and charting
4. In a relational database, a column is also called:
a) Tuple
b) Attribute
c) Relation
d) View
Answer: b) Attribute
5. In a relational database, the degree of a relation refers to:
a) Number of rows
b) Number of columns
c) Number of keys
d) Number of constraints
Answer: b) Number of columns
6. Which SQL statement is not a DDL command?
a) CREATE
b) DROP
c) UPDATE
d) ALTER
Answer: c) UPDATE
—-------------------------------------------------------------------------------------------------------------
2 Marks Question [2 X 4]
1. Define relation and tuple in the Relational Database Model.
Answer:
● Relation: A table with rows and columns.
● Tuple: A single row (record) in a relation.
2. Write two differences between Data Definition Language (DDL) and Data Manipulation Language
(DML).
Answer:
● DDL: Defines structure of database (e.g., CREATE, ALTER, DROP).
● DML: Manipulates data in tables (e.g., INSERT, UPDATE, DELETE).
3. Write SQL queries for the following using table STUDENT(Name, Marks):
a) Display names of students whose Marks are between 60 and 80.
b) Display names of students whose name starts with ‘A’.
Answer:
a) SELECT Name FROM STUDENT WHERE Marks BETWEEN 60 AND 80;
b) SELECT Name FROM STUDENT WHERE Name LIKE 'A%';
4. What do you mean by literals and null values in MySQL?
Answer:
● Literals: Fixed values like numbers (100), text ('Hello').
● Null Values: Represent unknown / missing data in a column.
—-------------------------------------------------------------------------------------------------------------
3 Marks Question [3 X 2]
1. Explain any three purposes of using a DBMS.
Answer:
1. Data Redundancy Control – DBMS avoids duplication of data.
2. Data Security – Access rights can be restricted.
3. Data Consistency – Ensures uniform and correct data across applications
2. Write SQL queries for the following using table EMPLOYEE(Name, Job, Salary, Commission):
a) Display unique jobs.
b) Display names of employees whose Salary > 30000.
c) Display Name and Commission, but show 0 if Commission is NULL.
Answer:
a) SELECT DISTINCT Job FROM EMPLOYEE;
b) SELECT Name FROM EMPLOYEE WHERE Salary>30000;
c) SELECT Name, IFNULL(Commission,0) FROM EMPLOYEE;
—-------------------------------------------------------------------------------------------------------------
5 Marks Question [5 X 4]
1. Answer the following questions based on MySQL (1 mark each):
a) Write the name of the clause used to eliminate duplicate values from the output.
b) Which function is used to display system date and time in MySQL?
c) Write a query to show the structure of a table EMPLOYEE.
d) Which operator is used in SQL for pattern matching with wildcards?
e) Write the output of: SELECT 10+5*2;
Solution:
a) DISTINCT
b) NOW()
c) DESC EMPLOYEE;
d) LIKE
e) 20 (because * has higher precedence: 5*2=10; 10+10=20)
2. Using the table EMPLOYEE(EmpID, Name, Salary, Job), answer the following:
a) Display the Name and annual salary (Salary*12) of all employees with column alias as
ANNUAL_SALARY.
b) Display names of employees whose job is either ‘CLERK’ or ‘MANAGER’.
c) Display names of employees whose salary is between 20000 and 40000.
Solution:
a) SELECT Name, Salary*12 AS ANNUAL_SALARY FROM EMPLOYEE;
b) SELECT Name FROM EMPLOYEE WHERE Job IN ('CLERK','MANAGER');
c) SELECT Name FROM EMPLOYEE WHERE Salary BETWEEN 20000 AND 40000;
3. Consider the table EMPLOYEE(EmpID, Name, Job, Salary, Commission) and answer the following
queries:
a) Write a query to display all details of employees.
b) Write a query to display all unique job titles.
c) Write a query to display employee names and commission, but if commission is NULL display 0.
Solution:
a) SELECT * FROM EMPLOYEE;
b) SELECT DISTINCT Job FROM EMPLOYEE;
c) SELECT Name, IFNULL(Commission,0) FROM EMPLOYEE;
4. Write SQL queries using functions:
a) Display the first 4 characters of employee names from EMPLOYEE.
b) Display the length of each student’s name from table STUDENT.
c) Display the square root of the Salary of each employee.
d) Display the current year from system date.
e) Display the highest Marks obtained by students.
Solution:
a) SELECT LEFT(Name,4) FROM EMPLOYEE;
b) SELECT Name, LENGTH(Name) FROM STUDENT;
c) SELECT SQRT(Salary) FROM EMPLOYEE;
d) SELECT YEAR(CURDATE());
e) SELECT MAX(Marks) FROM STUDENT;