0% found this document useful (0 votes)
11 views8 pages

CBSE Grade 12 SQL Theory & Questions

The document provides a comprehensive guide on SQL theory for CBSE Grade 12, covering key concepts such as Database Management Systems (DBMS), relational database models, keys, SQL command classifications, data types, constraints, aggregate functions, joins, and normalization. It includes theoretical explanations and exam questions with answers to help students understand and prepare for their exams. Important exam tips and common question patterns are also outlined to assist students in their study efforts.

Uploaded by

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

CBSE Grade 12 SQL Theory & Questions

The document provides a comprehensive guide on SQL theory for CBSE Grade 12, covering key concepts such as Database Management Systems (DBMS), relational database models, keys, SQL command classifications, data types, constraints, aggregate functions, joins, and normalization. It includes theoretical explanations and exam questions with answers to help students understand and prepare for their exams. Important exam tips and common question patterns are also outlined to assist students in their study efforts.

Uploaded by

hostelid3
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

[Link]

ai/public/artifacts/3c1249b7-58b0-4be4-b680-db7b8ab54e42 sql

CBSE Grade 12 SQL Theory with Exam


Questions
1. Database Management System (DBMS)
Theory Explanation

A Database Management System (DBMS) is software that manages databases by providing


an interface between users and the database. It handles data storage, retrieval, and
organization while ensuring data integrity and security.

Key Features:

 Data Independence: Applications are isolated from data storage details


 Data Integrity: Maintains accuracy and consistency
 Data Security: Controls access and protects sensitive information
 Concurrent Access: Multiple users can access data simultaneously
 Backup and Recovery: Protects against data loss

Exam Questions

Q1. (2 marks) Define DBMS. List any two advantages of DBMS over file system.

Answer: DBMS is software that manages databases by providing an interface for storing,
retrieving, and organizing data. Advantages: (1) Eliminates data redundancy (2) Ensures data
integrity and consistency

Q2. (3 marks) Differentiate between file system and DBMS on the basis of data redundancy,
data consistency, and data security.

Answer:

 Data Redundancy: File system has high redundancy; DBMS minimizes redundancy
 Data Consistency: File system lacks consistency; DBMS ensures consistency
 Data Security: File system has limited security; DBMS provides robust security
controls
2. Relational Database Model
Theory Explanation

The relational model organizes data in tables (relations) with rows (tuples) and columns
(attributes). Each table represents an entity, and relationships between entities are established
through keys.

Key Concepts:

 Table/Relation: Collection of related data entries


 Row/Tuple: Individual record in a table
 Column/Attribute: Field that represents a data type
 Domain: Set of allowable values for an attribute
 Degree: Number of columns in a table
 Cardinality: Number of rows in a table

Exam Questions

Q3. (2 marks) Define the terms: Tuple and Attribute in context of relational database.

Answer:

 Tuple: A row in a table representing a single record


 Attribute: A column in a table representing a field or property

Q4. (3 marks) What is the degree and cardinality of the following table?

StudentID Name Age Grade


101 John 16 A
102 Mary 17 B
103 Peter 16 A

Answer:

 Degree: 4 (number of columns)


 Cardinality: 3 (number of rows)

3. Keys in Relational Database


Theory Explanation

Primary Key: A column or combination of columns that uniquely identifies each row in a
table. Cannot contain NULL values.
Foreign Key: A column that creates a link between two tables by referencing the primary
key of another table.

Candidate Key: A column or combination of columns that can uniquely identify rows. A
table may have multiple candidate keys.

Alternate Key: Candidate keys that are not chosen as the primary key.

Exam Questions

Q5. (2 marks) Differentiate between Primary Key and Foreign Key.

Answer:

 Primary Key: Uniquely identifies each record in a table; cannot be NULL


 Foreign Key: References primary key of another table; establishes relationships
between tables

Q6. (4 marks) Consider the following tables:

Students Table:

StudentID Name ClassID


101 John C1
102 Mary C2

Classes Table:

ClassID ClassName Teacher


C1 Physics Dr. Smith
C2 Chemistry Dr. Jones

Identify the primary keys and foreign keys in both tables.

Answer:

 Students Table: Primary Key = StudentID, Foreign Key = ClassID


 Classes Table: Primary Key = ClassID, No Foreign Key

4. SQL Commands Classification


Theory Explanation

DDL (Data Definition Language):


 CREATE: Creates database objects
 ALTER: Modifies structure of existing objects
 DROP: Deletes database objects
 TRUNCATE: Removes all data from table but keeps structure

DML (Data Manipulation Language):

 INSERT: Adds new records


 UPDATE: Modifies existing records
 DELETE: Removes records

DQL (Data Query Language):

 SELECT: Retrieves data from database

DCL (Data Control Language):

 GRANT: Gives permissions


 REVOKE: Removes permissions

Exam Questions

Q7. (3 marks) Categorize the following SQL commands into DDL, DML, and DQL:
CREATE, SELECT, INSERT, ALTER, DELETE, DROP

Answer:

 DDL: CREATE, ALTER, DROP


 DML: INSERT, DELETE
 DQL: SELECT

Q8. (2 marks) What is the difference between DELETE and DROP commands?

Answer:

 DELETE: Removes specific rows from a table; table structure remains


 DROP: Removes entire table including structure and data

5. Data Types and Constraints


Theory Explanation

Common Data Types:

 INT: Integer numbers


 VARCHAR(n): Variable length strings up to n characters
 CHAR(n): Fixed length strings of exactly n characters
 DATE: Date values (YYYY-MM-DD)
 DECIMAL(p,s): Decimal numbers with p total digits and s decimal places

Constraints:

 NOT NULL: Field cannot be empty


 UNIQUE: All values must be different
 PRIMARY KEY: Combines NOT NULL and UNIQUE
 FOREIGN KEY: Maintains referential integrity
 CHECK: Validates data against a condition
 DEFAULT: Assigns default value if none provided

Exam Questions

Q9. (3 marks) Differentiate between CHAR and VARCHAR data types with examples.

Answer:

 CHAR(n): Fixed length; always uses n bytes (e.g., CHAR(10) for "ABC" uses 10
bytes)
 VARCHAR(n): Variable length; uses only required bytes (e.g., VARCHAR(10) for
"ABC" uses 3 bytes)

Q10. (4 marks) Write SQL command to create a table EMPLOYEE with the following
constraints:

 EmpID (Primary Key, Integer)


 Name (Not NULL, 30 characters max)
 Salary (Default 25000, must be > 0)
 DeptID (Foreign Key referencing DEPARTMENT table)

Answer:

CREATE TABLE EMPLOYEE (


EmpID INT PRIMARY KEY,
Name VARCHAR(30) NOT NULL,
Salary DECIMAL(10,2) DEFAULT 25000 CHECK (Salary > 0),
DeptID INT,
FOREIGN KEY (DeptID) REFERENCES DEPARTMENT(DeptID)
);

6. Aggregate Functions
Theory Explanation
Aggregate functions perform calculations on multiple rows and return a single result:

 COUNT(): Returns number of rows


 SUM(): Returns sum of numeric values
 AVG(): Returns average of numeric values
 MAX(): Returns largest value
 MIN(): Returns smallest value

These functions ignore NULL values (except COUNT(*)).

Exam Questions

Q11. (2 marks) What is the difference between COUNT(*) and COUNT(column_name)?

Answer:

 COUNT(*): Counts all rows including those with NULL values


 COUNT(column_name): Counts only rows where the specified column is not NULL

Q12. (3 marks) Consider a table SALES with columns: ProductID, Quantity, Price. Write
SQL commands to find: (a) Total quantity sold (b) Average price of products (c) Number of
different products sold

Answer:

(a) SELECT SUM(Quantity) FROM SALES;


(b) SELECT AVG(Price) FROM SALES;
(c) SELECT COUNT(DISTINCT ProductID) FROM SALES;

7. Joins
Theory Explanation

Joins combine data from multiple tables based on related columns:

INNER JOIN: Returns records with matching values in both tables LEFT JOIN: Returns
all records from left table and matching records from right table RIGHT JOIN: Returns all
records from right table and matching records from left table FULL OUTER JOIN: Returns
all records from both tables

Exam Questions

Q13. (3 marks) Differentiate between INNER JOIN and LEFT JOIN with examples.

Answer:

 INNER JOIN: Returns only matching records from both tables


 SELECT * FROM Students s INNER JOIN Classes c ON [Link] =
[Link];
 LEFT JOIN: Returns all records from left table and matching records from right
table
 SELECT * FROM Students s LEFT JOIN Classes c ON [Link] =
[Link];

8. Normalization
Theory Explanation

Normalization eliminates data redundancy and ensures data integrity:

1NF (First Normal Form):

 Each column contains atomic (indivisible) values


 No repeating groups

2NF (Second Normal Form):

 Must be in 1NF
 All non-key attributes fully depend on the primary key

3NF (Third Normal Form):

 Must be in 2NF
 No transitive dependencies (non-key attributes don't depend on other non-key
attributes)

Exam Questions

Q14. (4 marks) What is normalization? Explain 1NF with an example.

Answer: Normalization is the process of organizing data to reduce redundancy and improve
data integrity.

1NF: Each column must contain atomic values and no repeating groups.

Violation Example:

StudentID Name Subjects


101 John Math, Physics

1NF Compliant:

StudentID Name Subject


101 John Math
101 John Physics
9. Important Exam Tips
Common Question Patterns

2-Mark Questions:

 Define terms (DBMS, Primary Key, etc.)


 Differentiate between concepts
 Identify data types or constraints

3-Mark Questions:

 Explain concepts with examples


 Write simple SQL commands
 Compare multiple concepts

4-5 Mark Questions:

 Create table structures with constraints


 Write complex SQL queries
 Explain normalization with examples

Key Points to Remember

1. Always use proper SQL syntax in answers


2. Give examples when explaining concepts
3. Be precise with technical definitions
4. Show table structures clearly in diagrams
5. Practice writing queries without computer assistance

This comprehensive guide covers all major theoretical concepts with exam-style questions
that frequently appear in CBSE Grade 12 Computer Science papers.

[Link]

Common questions

Powered by AI

Normalization is the process of organizing data to minimize redundancy and dependency by dividing a database into two or more tables and defining relationships between them . Achieving 2NF is crucial as it ensures that all non-key attributes are fully dependent on the primary key, thus eliminating partial dependencies that can lead to anomalies in data insertion, deletion, and updating. In a practical context, 2NF eliminates subsets of data that apply to multiple rows and places them in separate tables to maintain consistency .

The implementation of a FOREIGN KEY constraint ensures referential integrity by preventing changes in a related table that would produce invalid links, thus maintaining database consistency . A major benefit is the automatic enforcement of relational links that prevent orphaned records. However, risks include increased complexity in schema design and potential performance bottlenecks, as every insert, update, or delete must be verified against the foreign key constraint, which could affect performance in high-transaction environments. Additionally, mishandling of foreign keys can lead to circular dependencies during the design phase .

CHAR is a fixed-length data type that always stores strings of a specified length, padding with spaces if necessary, while VARCHAR is a variable-length data type that stores strings as entered, using only the required space . This means CHAR can be less efficient in terms of disk space, especially when storing a large number of short strings. However, it can offer performance benefits in terms of data retrieval speed because the fixed size can simplify memory access .

CHECK constraints validate data against specified conditions before insertion or update, ensuring that only data meeting certain criteria can be entered into a table, thus enhancing data integrity by systematically avoiding unwanted entries . DEFAULT constraints automatically populate a column with a predetermined value if no explicit data is provided, increasing usability by simplifying data entry processes and ensuring that critical fields are not left blank, which aids in maintaining consistency across records .

A DBMS ensures data integrity and consistency by implementing constraints such as primary keys, foreign keys, and unique constraints, which enforce rules on data storage and relationships . Unlike traditional file systems, which rely on manual processes, a DBMS uses transaction management to ensure atomicity, consistency, isolation, and durability (ACID properties), preventing inconsistencies during concurrent data operations .

The DELETE command is used when there is a need to remove specific rows from a table without affecting the table's structure, which is essential when only a subset of data needs to be purged, and the table will continue to be used . In contrast, the DROP command should be used when the complete removal of a table, including its structure and all of its records, is necessary. This is suitable for permanently retiring unused tables, freeing up database space, and simplifying schema management. Choosing DELETE avoids the loss of table structure and permissions, which could be beneficial when anticipating future use of the corresponding data schema .

Aggregate functions such as SUM() and AVG() process multiple rows of data and return a single summarized result . These functions, except for COUNT(*), ignore NULL values during calculations, meaning they only operate on rows where the specified column is non-null. For example, SUM() will add up all non-null values in a column, and AVG() will compute the average by dividing the sum by the count of non-null entries, ensuring more accurate results in the presence of missing data .

LEFT JOIN returns all records from the left table and the matched records from the right table, filling non-matching rows with NULLs. This is advantageous when it is necessary to include all data from the left table irrespective of matches, such as when performing audits or generating comprehensive reports . Conversely, INNER JOIN only returns records with matching values in both tables, optimizing performance as fewer rows are processed, which can be beneficial in performance-critical applications. However, LEFT JOIN might lead to increased processing time and memory use with larger datasets due to the inclusion of potentially entire tables .

Primary keys uniquely identify each record in a table, ensuring that each entry can be efficiently referenced and accessed. Foreign keys, on the other hand, reference primary keys in another table to establish a relational link between the data entities, thereby maintaining referential integrity . A foreign key cannot contain null values when it is used to establish a mandatory relationship because a null in the foreign key would indicate a lack of association with a primary key, thus breaking the linkage and potentially leading to orphaned records and compromised data integrity .

Practicing query writing without computer assistance is crucial because it forces students to internalize SQL syntax and logic, enhancing their problem-solving skills without relying on automated feedback from software tools . This practice helps in developing a deeper understanding of query structures and reduces dependence on syntax highlighting and autocompletion, which can lead to over-reliance on tools rather than a comprehensive understanding of the syntax. During exams, students cannot use computers for verification, so this practice prepares them to write accurate queries in a test environment .

You might also like