Database Concepts Questions and Answers Class 12 IT (802)
Don’t miss out on revising these Important Database Concepts Questions and Answers for Class 12 IT (802) before your CBSE Board Exam! This carefully prepared question bank features non-repetitive, subjective, board-oriented and application-based questions, strictly following the SQL syntax, commands and terminology used in the NCERT textbook and CBSE curriculum.
This complete collection of Database Concepts Important Questions and Answers for Class 12 has been developed after carefully analysing previous CBSE board exam papers, frequently asked questions, question patterns and their trends. It covers all major topics, including database fundamentals, the relational model, constraints, MySQL installation, SQL data types, database and table creation, table modification, data manipulation, data retrieval, filtering, sorting, joins, nested queries, aggregate functions and grouping.
Whether you are preparing for short-answer questions, long-answer questions or practical-based SQL questions, this question bank will help you strengthen your concepts and improve your exam preparation.
Don’t skip a single question! Practise the complete set, master important SQL concepts and commands, and prepare with confidence to aim for full marks in your CBSE Class 12 IT (802) Board Exam. 🚀
Section A: Subjective Answer Questions
Q1. Differentiate between data and information.
Answer: Data is a collection of raw facts that have not been processed to reveal anything useful. Information is the meaningful result obtained by processing data. For example, students’ marks are data, while the class average, maximum and minimum marks are information about class performance.
Q2. Define a database.
Answer: A database is a collection of related data that has been recorded, organized and made available for searching.
Q3. State any two properties of a database.
Answer:
(i) It is designed, built and populated with data for a specific purpose.
(ii) It can be of any size and complexity. It can also be maintained manually or by computer.
Q4. Explain data redundancy.
Answer: Data redundancy occurs when the same information is stored in more than one file. It results in unnecessary duplication and wastage of storage space.
Q5. What is data inconsistency? Give one example.
Answer: Data inconsistency occurs when similar information stored in different files is not updated uniformly.
Example: A salesperson’s salary is updated in the Payroll file but remains unchanged in another file containing the same information.
Q6. Define DBMS. Give two examples.
Answer: A DBMS (Database Management System) is a collection of programs that enables users to create, maintain and use a database. It maintains one repository of data that is defined once and accessed by many users.
Examples: MySQL and Oracle.
Q7. What is metadata? Where is it stored?
Answer: Metadata is the description of the data stored in a database. It is stored in a database catalogue or data dictionary.
Q8. Explain Program-Data Independence.
Answer: Program-Data Independence is the property of a DBMS in which changes in the data structure do not necessarily require modifications to the programs that access the data.
Q9. State any two advantages of the DBMS.
Answer:
- Reduction in data redundancy.
- Improved data consistency.
Q10. Mention any two limitations of the DBMS.
Answer:
- High cost of implementation.
- Security and recovery overheads.
Q11. What is a relational database? Who developed the relational database model and in which year?
Answer: A relational database organises data as a collection of relations, where each relation corresponds to a table of values. E. F. Codd developed the relational database model at IBM in 1970.
Q12. Explain the following relational model terms:
(i) Tuple
(ii) Attribute
(iii) Relation
(iv) Domain
(v) Degree
(vi) Cardinality
(vii) Relation Schema
(viii) Relation State
(ix) NULL
Answer:
(i) Tuple: A single row in a relation, representing one record.
(ii) Attribute: A column in a relation. For example: Roll_No, Name, Class.
(iii) Relation: A table in the relational model, consisting of rows (tuples) and columns (attributes).
(iv) Domain: The set of all permissible atomic (indivisible) values that an attribute can take.
(v) Degree: The total number of attributes (columns) in a relation. A relation with 4 columns has degree 4.
(vi) Cardinality: The total number of tuples (rows) present in a relation at a given time. A relation with 50 rows has cardinality 50.
(vii) Relation Schema: The structural description of a relation, consisting of the relation name followed by its list of attributes, usually with their domains.
(viii) Relation State: The set of tuples present in a relation at a particular moment in time. It is also called the relation instance.
(ix) NULL: It is used to represent an attribute value that is unknown, unavailable or not applicable.
Q13. Differentiate between degree and cardinality of a relation.
Answer:
- Degree: The number of attributes (columns) in a relation.
- Cardinality: The number of tuples (rows) in a relation.
Q14. What is an RDBMS? Give two examples.
Answer: A Relational Database Management System (RDBMS) is a DBMS based on the relational model. Examples: MySQL and Oracle.
Q15. What is a candidate key?
Answer: A candidate key is a minimal set of one or more attributes that can uniquely identify each tuple (row) in a relation. It is eligible to be selected as the primary key.
Q16. What is a primary key? State one property.
Answer: A primary key is a candidate key selected to uniquely identify each tuple (row) in a relation.
Property: A primary key cannot contain NULL values, and its values must be unique.
Q17. Differentiate between a candidate key and a primary key.
Answer:
| Candidate Key | Primary Key |
| A candidate key is a minimal set of attributes that can uniquely identify each tuple in a relation. | A primary key is the candidate key selected to uniquely identify each tuple in a relation. |
| A relation can have multiple candidate keys. | A relation can have only one primary key. |
| A candidate key is eligible for selection as the primary key. | A primary key is selected from the available candidate keys. |
Q18. What is a foreign key?
Answer: A foreign key is an attribute or set of attributes in one relation that refers to the primary key of another relation or the same relation.
Q19. Differentiate between Primary key and Foreign key.
Answer:
| Primary Key | Foreign Key |
| It is a field that uniquely identifies each record in a table. | It is a field that establishes a relationship between two tables by referring to the primary key of another table. |
| It does not allow duplicate or NULL values. | It may contain duplicate or NULL values, depending on the table constraints. |
Q20. Explain entity integrity constraint.
Answer: Entity integrity constraint specifies that the primary key of a relation cannot contain NULL values.
Q21. Explain referential integrity constraint.
Answer: Referential integrity constraint ensures that a foreign key value in one relation corresponds to a valid referenced primary key value in another relation, or is NULL where permitted.
Q22. What is SQL?
Answer: SQL (Structured Query Language) is a standard language used to create, access, manipulate and manage data in relational database management systems (RDBMS).
Q23. Name the two components of SQL and state the purpose of each.
Answer: The two main components of SQL are:
1. Data Definition Language (DDL): Used to define, create and modify the structure of database objects and their constraints.
2. Data Manipulation Language (DML): Used to insert, update and delete records in a database.
Q24. Differentiate between DDL and DML.
Answer:
| DDL (Data Definition Language) | DML (Data Manipulation Language) |
| Used to define and modify the structure of database objects. | Used to insert, update and delete data in a database. |
| It deals with the database schema (structure). | It deals with the records (data) stored in tables. |
| Examples: CREATE, ALTER, DROP. | Examples: INSERT, UPDATE, DELETE. |
Q25. Differentiate between CHAR(n) and VARCHAR(n).
Answer:
| CHAR(n) | VARCHAR(n) |
| It is a fixed-length character data type. | It is a variable-length character data type. |
| It stores exactly n characters. If the entered value is shorter, the remaining space is padded with blanks. | It stores only the characters entered, up to a maximum of n characters. |
| Suitable for values with a fixed length, such as gender codes or PIN codes of fixed length. | Suitable for values with varying lengths, such as names and email addresses. |
Q26. Name any four aggregate functions of SQL and explain their purpose.
Answer:
| Aggregate Function | Purpose |
| COUNT() | Counts the number of rows (tuples) in a result. |
| SUM() | Calculates the total of a numeric column. |
| MAX() | Returns the maximum value in a column. |
| MIN() | Returns the minimum value in a column. |
Q27. Explain any three characteristics of relations.
Answer:
1. The ordering of tuples in a relation is unimportant.
2. The ordering of attributes is unimportant.
3. No two tuples in a relation should be identical.
Q28. Consider the relation PERSON (Aadhar_number, PAN, Voter_ID_cardno, Name, Date_of_birth, Address). If Aadhar_number, PAN and Voter_ID_cardno are individually unique, explain the candidate keys and primary key.
Answer:
The candidate keys are:
- {Aadhar_number}
- {PAN}
- {Voter_ID_cardno}
Any one of these candidate keys may be selected as the primary key. If Aadhar_number is selected, it becomes the primary key of the relation.
Q29. Explain following SQL data types:
(i) CHAR(n) (i) VARCHAR(n) (iii) INTEGER (iv) DATE
Answer:
1. CHAR(n): Stores a fixed-length character string of n characters.
2. VARCHAR(n): Stores a variable-length character string with a maximum of n characters.
3. INTEGER: Stores integer numbers.
4. DATE: Stores a date in the format YYYY-MM-DD.
Q30. Explain following SQL constraints with Suitable example:
(i) NOT NULL (ii) DEFAULT
Answer:
1. NOT NULL: Prevents an attribute from containing NULL values.
Example: First_Name VARCHAR(20) NOT NULL
2. DEFAULT: Assigns a specified value when the user does not enter a value for the attribute.
Example: Salary DECIMAL(10,2) DEFAULT 40000
Q31. What is the purpose of the ALTER TABLE command in SQL? Write SQL commands for the followings:
(i) add a new column
(ii) drop a column
Answer:
The ALTER TABLE command is used to modify the definition of an existing table.
(i) Adding a column:
ALTER TABLE Teacher ADD Age INTEGER;
(ii) Dropping a column:
ALTER TABLE Teacher DROP Age;
Q32. Explain the purpose of following SQL commands
(i) SELECT (ii) DISTINCT
Answer:
(i) SELECT: The SELECT command is used to retrieve or display data from one or more tables in a database.
Example: SELECT * FROM Teacher;
(ii) DISTINCT: The DISTINCT keyword is used with SELECT to display only unique values by eliminating duplicate values from the result.
Example: SELECT DISTINCT Dept_No FROM Teacher;
Q33. Explain the purpose of following SQL commands
(i) ORDER BY (ii) GROUP BY
Answer:
(i) ORDER BY: Sorts the records in a result set in ascending (ASC) or descending (DESC) order based on one or more columns.
Example:
SELECT * FROM Teacher
ORDER BY Salary DESC;
(ii) GROUP BY: Groups rows having the same values in specified columns, allowing aggregate functions to be applied to each group.
Example:
SELECT Dept_No, COUNT(*) FROM Teacher
GROUP BY Dept_No;
Q34. Explain string pattern matching using the LIKE operator with example
Answer:
The LIKE operator is used for pattern matching in SQL. It uses two wildcard characters:
- % : Represents zero or more characters.
- _ : Represents exactly one character.
Example: Names starting with ‘S’
SELECT First_Name FROM Teacher
WHERE First_Name LIKE ‘S%’;
Q35. Explain the purpose of following SQL clause
(i) WHERE (ii) HAVING
Answer:
(i) WHERE: The WHERE clause is used to retrieve specific records based on a specified condition.
Example: Displays only those teachers whose salary is greater than 30000.
SELECT * FROM Teacher
WHERE Salary > 30000;
(ii) HAVING: The HAVING clause is used to filter groups of records based on a specified condition. It is generally used with the GROUP BY clause and aggregate functions.
Example:
SELECT Dept_No, COUNT(*) FROM Teacher
GROUP BY Dept_No HAVING COUNT(*) > 2;
Difference between WHERE and HAVING:
| WHERE | HAVING |
| Filters individual rows. | Filters groups of records. |
| Used before GROUP BY. | Used after GROUP BY. |
| Cannot directly apply conditions on aggregate results. | Can apply conditions on aggregate results. |
Section-B: SQL Command based Questions
Q36. Write SQL commands to create a database School, display all databases, and select School for use.
Answer:
CREATE DATABASE School;
SHOW DATABASES;
USE School;
Q37. Write the SQL statement to delete all the rows of the Teacher table without deleting the table.
Answer:
DELETE FROM Teacher;
Q38. Write a command to increase the salary of the teacher with Teacher_ID 101 by 5000.
Answer:
UPDATE Teacher
SET Salary = Salary + 5000
WHERE Teacher_ID = 101;
Q39. Write a query to display the first names of all teachers whose names start with the letter ‘S’.
Answer:
SELECT First_Name
FROM Teacher
WHERE First_Name LIKE “S%”;
Q40. Write a query to display all details of teachers whose last name is not specified.
Answer:
SELECT * FROM Teacher
WHERE Last_Name IS NULL;
Q41. Which keyword removes repeated values from the result of a query? Write a query to list the department numbers of male teachers without repetition.
Answer: The keyword is DISTINCT.
SELECT DISTINCT Dept_No
FROM Teacher
WHERE Gender = ‘M’;
Q42. What is an alias? Write a query that shows First_Name as Fname.
Answer: An alias is a temporary name given to a table or column using the keyword AS, used to resolve ambiguity or improve readability.
SELECT First_Name AS Fname
FROM Teacher;
Q43. Write a query to list the names of all departments in descending order of name.
Answer:
SELECT Dept_Name
FROM Department
ORDER BY Dept_Name DESC;
Section-C: Case-Based Questions (5 Sub-Questions Each)
Case Study-1
Consider the following table PRODUCTS:
Table: PRODUCTS
| ProductID | ProductName | SupplierID | StockQty | Price |
| 2001 | KEYBOARD | 301 | 150 | 450 |
| 2002 | MOUSE | 302 | 120 | 250 |
| 2003 | USB DRIVE | 303 | 180 | 600 |
| 2005 | HEADPHONE | 301 | 110 | 800 |
| 2007 | SPEAKER | 304 | 90 | 1200 |
| 2010 | WEBCAM | 302 | 130 | 950 |
| 2012 | MOUSE PAD | 304 | 105 | 150 |
Write SQL queries for the following requirements:
a) Retrieve all details of products from the PRODUCTS table, sorted in ascending order of Price.
Answer:
SELECT * FROM PRODUCTS
ORDER BY Price ASC;
b) Display ProductID and ProductName for those products in the PRODUCTS table whose StockQty exceeds 120.
Answer:
SELECT ProductID, ProductName
FROM PRODUCTS
WHERE StockQty > 120;
c) Retrieve all details of products from the PRODUCTS table where SupplierID is 301 or Price is less than 500.
Answer:
SELECT * FROM PRODUCTS
WHERE SupplierID = 301 OR Price < 500;
d) Display each SupplierID along with the count of ProductName supplied by that supplier.
Answer:
SELECT SupplierID, COUNT(ProductName)
FROM PRODUCTS
GROUP BY SupplierID;
Case Study 2:
A company maintains the following EMPLOYEE relation:
| Name | Employee_ID | Gender | Salary | Date_of_Birth |
| Neha Mehta | 1121 | Female | 20000 | 04-03-1990 |
| Paras Bansal | 2134 | Male | 25000 | 19-10-1993 |
| Himani Verma | 3145 | Female | 20000 | 23-11-1992 |
Based on the above relation, answer the following questions.
a) What is the degree of the EMPLOYEE relation?
Answer: 5.
b) What is the cardinality of the EMPLOYEE relation?
Answer: 3.
c) What is the term used for each row of this relation?
Answer: Tuple.
d) What is the term used for each column of this relation?
Answer: Attribute.
Q52. If Employee_ID uniquely identifies each employee and is a minimal superkey, what type of key is it?
Answer: It is a Candidate Key. If it is selected to uniquely identify the tuples in the relation, it becomes the Primary Key.
Case Study 3:
Consider the following table STUDENT:
Table: STUDENT
| RollNo | StudentName | Stream | Marks | Gender |
| 1 | ANJALI | SCIENCE | 88 | F |
| 2 | VIKAS | COMMERCE | 75 | M |
| 3 | RHEA | SCIENCE | 92 | F |
| 4 | KARAN | HUMANITIES | 68 | M |
| 5 | MEERA | COMMERCE | 85 | F |
| 6 | ARJUN | HUMANITIES | 78 | M |
| 7 | TANVI | SCIENCE | 80 | F |
Write SQL queries for the following requirements:
a) Display the names of students whose names begin with the letter ‘A’.
Answer:
SELECT StudentName
FROM STUDENT
WHERE StudentName LIKE ‘A%’;
b) Display the StudentName and Marks of students who have scored 80 or more marks and belong to the SCIENCE stream.
Answer:
SELECT StudentName, Marks
FROM STUDENT
WHERE Marks >= 80 AND Stream = ‘SCIENCE’;
c) Display the names and marks of all students sorted in descending order of Marks.
Answer:
SELECT StudentName, Marks
FROM STUDENT
ORDER BY Marks DESC;
d) Count the number of students in each Stream.
Answer:
SELECT Stream, COUNT(*)
FROM STUDENT
GROUP BY Stream;