Courses
Courses for Kids
Free study material
Offline Centres
More
Store Icon
Store

Class 12 Computer Science Chapter 9 Structured Query Language (SQL) – NCERT Solutions

ffImage
banner

Stepwise Solutions & Important SQL Queries for CBSE Class 12 Computer Science

Confused about NCERT Solutions for Class 12 Computer Science Chapter 9 Structured Query Language Sql? You’re in the right place! Here you’ll find clear, exam-friendly steps for every SQL exercise as per the CBSE 2025–26 syllabus, so difficult queries won’t feel overwhelming anymore.


From handy class 12 SQL solutions and exercise-wise answers to tips that match the CBSE marking scheme, our guide makes your practice simple and stress-free. Download the free PDF for easy revision and offline access whenever you need it.


Get stepwise SQL query examples, key definitions, and proven presentation tips—all in line with the marking rubrics. Boost your accuracy and confidence with resources crafted by subject experts for full marks in your Computer Science exam.


Stepwise Solutions & Important SQL Queries for CBSE Class 12 Computer Science

1. Answer the following questions in about 30 words.


1. What is SQL? Name two popular RDBMS which use SQL as their query language.


Answer: SQL (Structured Query Language) is a standard programming language used to manage and manipulate relational databases. Two popular RDBMS that use SQL are MySQL and Oracle.


2. What is the difference between CHAR and VARCHAR data types in MySQL?


Answer: CHAR stores fixed-length character strings and always uses the same amount of space, even if not fully filled. VARCHAR stores variable-length strings and uses only as much space as needed for each value.


3. What is the use of PRIMARY KEY and FOREIGN KEY constraints in a table?


Answer: PRIMARY KEY uniquely identifies each row in a table and does not allow null values. FOREIGN KEY is used to establish a relationship between two tables by linking to the primary key of another table.


4. What is a composite key? Give an example from the chapter.


Answer: A composite key uses two or more columns together to uniquely identify a row in a table. In the ATTENDANCE table, AttendanceDate and RollNumber together form a composite primary key.


5. What are DDL and DML statements? Give one example of each.


Answer: DDL (Data Definition Language) statements are used to define or modify the database schema (e.g., CREATE TABLE). DML (Data Manipulation Language) statements are used to manipulate data (e.g., INSERT INTO).


2. Answer the following questions in about 150 words.


1. Explain the process and steps to create a relational database and associated tables in MySQL as discussed in the chapter.


Answer: To create a relational database, first install MySQL and start its service. Use the CREATE DATABASE statement to create a new database (e.g., CREATE DATABASE StudentAttendance;). Select the database using the USE statement. Then, create tables using CREATE TABLE, defining columns, datatypes, and constraints like PRIMARY KEY or FOREIGN KEY. For instance, the STUDENT table is created with columns RollNumber, SName, SDateofBirth, and GUID, specifying data types and primary key. Tables are linked using foreign keys to establish relationships, such as GUID in the STUDENT table referring to GUID in GUARDIAN. After table creation, data can be inserted using INSERT statements. Other optional steps include altering tables with the ALTER statement or removing them using DROP.


2. What is the importance of constraints in relational databases? Discuss at least three different types of constraints with examples from the chapter.


Answer: Constraints ensure data integrity and accuracy in relational databases. NOT NULL constraint ensures columns must be filled, e.g., SName in STUDENT is NOT NULL. UNIQUE constraint makes sure all values in a column are distinct, like GPhone in GUARDIAN. PRIMARY KEY uniquely identifies each row, as RollNumber in STUDENT, avoiding duplicate records. FOREIGN KEY creates relationships between tables, as GUID in STUDENT references GUARDIAN. DEFAULT sets a predefined value if none given; for example, SDateofBirth can have DEFAULT '2000-05-15'.


3. Match the following.


Questions Answer
1. CHAR(n) (C) Fixed length string
2. VARCHAR(n) (D) Variable length string
3. PRIMARY KEY (A) Uniquely identifies a row
4. FOREIGN KEY (B) References a primary key in another table

4. Write SQL statements for the following tasks based on the schema discussed in the chapter.


  • (a) Create the GUARDIAN table (without constraints).
  • (b) Add a primary key to the GUARDIAN table.
  • (c) Add UNIQUE constraint to GPhone in GUARDIAN table.
  • (d) Add a new column income of type INT to GUARDIAN table.
  • (e) Remove the column income from GUARDIAN table.

Answer:

  • (a) CREATE TABLE GUARDIAN(GUID CHAR(12), GName VARCHAR(20), GPhone CHAR(10), GAddress VARCHAR(30));
  • (b) ALTER TABLE GUARDIAN ADD PRIMARY KEY (GUID);
  • (c) ALTER TABLE GUARDIAN ADD UNIQUE(GPhone);
  • (d) ALTER TABLE GUARDIAN ADD income INT;
  • (e) ALTER TABLE GUARDIAN DROP income;

5. Differentiate between the following statements:


  • (a) ALTER and UPDATE
  • (b) DELETE and DROP

Answer:

  • (a) ALTER is used to modify the structure of a table (e.g., add or remove columns, change data types), while UPDATE is used to change data values within table rows.
  • (b) DELETE removes specific rows from a table based on a condition, while DROP deletes the entire table or database, including its structure and data.

Mastering Structured Query Language (SQL) in Class 12 Computer Science

Understanding SQL fundamentals is vital for scoring high in Computer Science Class 12. This NCERT Solutions chapter focuses on data definition, manipulation, and constraints in MySQL, helping you strengthen your basics and improve practical database skills.


By practicing chapter-wise NCERT exercises, students can learn core concepts such as DDL, DML, primary keys, foreign keys, and data types. Regular revision of these SQL queries ensures deeper understanding and fast problem-solving during exams.


Stay consistent with your preparation. Focus on solving exercise-based SQL questions, reviewing all constraints and commands. This approach not only boosts conceptual clarity but also builds confidence for practical computer science exams.


FAQs on Class 12 Computer Science Chapter 9 Structured Query Language (SQL) – NCERT Solutions

1. What is the best way to solve NCERT Solutions for Class 12 Computer Science Chapter 9 Structured Query Language (SQL)?

The best way to solve NCERT Solutions for Class 12 Computer Science Chapter 9 (Structured Query Language) is with a step-by-step, exercise-wise approach matching the CBSE exam pattern.

  • Start by understanding core SQL concepts, definitions, and syntax.
  • Write stepwise answers for each NCERT question, including SQL queries, explanations, and relevant examples.
  • Use clear formatting, proper code indentation, and comments in your answers.
  • Revise key SQL commands like SELECT, WHERE, GROUP BY, and JOIN with practical examples from the chapter.
  • Follow the marking scheme: definitions, correct SQL query, structured steps.

2. Are NCERT Solutions enough for Class 12 Computer Science exams?

NCERT Solutions for Class 12 Computer Science Chapter 9 are generally sufficient to prepare for exams, provided you also understand key SQL concepts and syntax.

  • Focus on answering all in-text, back exercises, and exemplar questions.
  • Practice extra SQL queries for deeper understanding and scoring full marks.
  • Use additional sample papers and previous year questions for thorough exam readiness.

3. How do I write stepwise NCERT answers to score full marks for this chapter?

To score full marks in Class 12 Computer Science Structured Query Language questions, structure your answer in clear, exam-aligned steps.

  • Start with definitions or concepts if required.
  • Write correct SQL syntax, with keywords in uppercase.
  • Explain each line of query briefly if it's a long answer.
  • Maintain indentation and comment on important clauses.
  • Underline or highlight key terms/commands.
  • Conclude with the expected output or result, if asked.

4. What topics are covered in Class 12 Computer Science Chapter 9 Structured Query Language (SQL)?

NCERT Class 12 Computer Science Chapter 9 covers the basics and advanced features of SQL, including:

  • Definition and need for SQL
  • Understanding Data Definition Language (DDL) and Data Manipulation Language (DML) commands
  • SELECT, INSERT, UPDATE, DELETE queries
  • Using WHERE, ORDER BY, GROUP BY, HAVING
  • Joins and relationships between tables
  • Writing queries based on single/multiple tables

5. Which Structured Query Language (SQL) questions from Chapter 9 are most likely in my CBSE school exams?

The most expected questions for CBSE Class 12 Computer Science Chapter 9 usually involve:

  • Writing SQL queries for given tables and output.
  • Explaining SQL commands: SELECT, WHERE, GROUP BY, JOIN.
  • Identifying errors and correcting SQL statements.
  • Definition-based short answers and difference between DDL/DML.
  • Query-based questions with two tables (joins).

6. Are definitions or SQL query syntax compulsory in answers?

Yes, definitions and correct SQL query syntax are essential for scoring full marks in NCERT and CBSE exams.

  • Always begin with a definition if the question mentions "define" or "explain".
  • Write SQL queries with proper syntax (uppercase keywords, semicolons).
  • Diagrams, if any, should be neat and labelled as per marking scheme.

7. How do I structure long SQL answers for better marks?

To present long SQL answers:

  • Step 1: Begin with the context or requirement.
  • Step 2: Write each SQL query stepwise, explaining the logic.
  • Step 3: Comment on key clauses like WHERE/GROUP BY.
  • Step 4: Show the expected output format or table structure, if needed.
  • Tip: Number your steps or label each part clearly.

8. Where can I download the PDF for all Chapter 9 solutions?

You can download the complete NCERT Solutions for Class 12 Computer Science Chapter 9 SQL in PDF format for free.

  • Look for the download PDF button on the solution page.
  • The PDF includes step-by-step answers for all exercises (intext, back, exemplar).
  • Offline access helps during last-minute revision and practice.

9. What are the most common mistakes in Class 12 SQL answers and how can I avoid them?

The most common mistakes students make in Class 12 Computer Science SQL answers are:

  • Incorrect SQL syntax or spelling errors (e.g., select instead of SELECT)
  • Missing semicolons or brackets.
  • Forgetting to specify table names or columns.
  • Not writing definitions or explanations where required.
  • Incorrect output/table format.

To avoid these:
  • Revise SQL syntax rules regularly.
  • Read questions carefully before writing queries.
  • Practice past year and exemplar questions to avoid losing marks.

10. How can I revise Class 12 Computer Science Chapter 9 Structured Query Language (SQL) quickly?

For fast and effective revision of Class 12 Computer Science Chapter 9:

  • Review all key definitions, formulae, and SQL commands.
  • Practice at least 5 sets of SQL queries on one and two tables each.
  • Go through stepwise solutions and typical exam questions.
  • Use quick notes and flashcards for key concepts like DML commands and JOIN clauses.
  • Attempt sample papers and MCQs to test understanding.

11. Do examiners award partial marks for correct steps even if the final answer is wrong?

Yes, CBSE examiners often award partial marks for correctly written steps or logic, even if the final SQL output has minor mistakes.

  • Each part of the answer (definition, steps, SQL statement, explanation) is marked separately.
  • Follow the marking scheme and always write each step clearly to maximize your score.

12. Are references to textbook page numbers useful during revision?

Referring to NCERT textbook page numbers during revision can help quickly locate important solved examples and explanations.

  • It is especially helpful for intext questions and exercises.
  • Always cross-check your answers with textbook solutions for accuracy.