Skip to content
← Informatics Practices

Informatics Practices · Class 12 Optional

Ch 1Querying and SQL Functions — Class 12 Informatics Practices, concept-first.

In Class XI, you learned the fundamentals of databases — how to create them in MySQL, populate them with data, and retrieve that data using SQL queries. This chapter builds directly on that foundation.

40

Q&A

15

Concepts

Not available

Exam weightage

Start learning — read this chapter →

Key concepts

Hover a concept to preview it and jump to its most relevant Q&A.

Chapter contents

The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.

1.1

Introduction

In Class XI, you learned the fundamentals of databases — how to create them in MySQL, populate them with data, and retrieve that data using SQL queries.

1.2

Functions in SQL

Functions are a core part of SQL, just as they are in programming languages. A function takes some input, performs a specific task, and returns a result.

1.2.1

Single Row Functions

Single row functions are also known as scalar functions. They are applied on a single value and return a single value — one output for every row they process.

(A)

Numeric Functions

3 Q

Numeric (math) functions take numbers in and give numbers out. The textbook works with three commonly used ones — POWER(), ROUND() and MOD() — whose syntax and worked outputs are listed in Table 1.5:

(B)

String Functions

3 Q

String functions perform operations on alphanumeric data — changing case, extracting a substring, measuring length, locating one string inside another, and stripping unwanted spaces.

(C)

Date and Time Functions

3 Q

Date and time functions operate on date and time data — displaying the current date, extracting a date's day/month/year, or naming the day of the week.

1.2.2

Aggregate Functions

2 Q

Aggregate functions are also called multiple-row functions. Unlike single-row functions that work on one row at a time, aggregate functions work on a whole set of records at once.

1.3

GROUP BY in SQL

2 Q

The whole point of GROUP BY is to stop treating your table as a list of individual rows and start treating it as a collection of groups.

1.4

Operations on Relations

Operations on relations let us combine or compare data from two tables. The textbook introduces three such operations: Union, Intersection, and Set Difference.

1.4.1

Union (U)

The Union operation combines the selected rows from two tables into a single result. If a row appears in both tables, it is shown only once in the output — duplicates are automatically removed.

1.4.2

Intersect (∩)

The INTERSECT operation, denoted by the symbol ∩, is used to find common tuples (rows) that appear in two tables.

1.4.3

Minus (-)

The MINUS operation, written with the minus sign (−), answers a simple question: Which rows exist in the first table but not in the second? It is also called set difference.

1.4.4

Cartesian Product

The Cartesian product is a set operation that combines every row from one relation with every row from another relation.

1.5

Using Two Relations in a Query

We have so far written every query using only one table — a single relation. But real databases store related data across multiple tables.

1.5.1

Cartesian Product on Two Tables

The Cartesian product is the operation that underlies every query involving more than one table. When you list multiple tables in the FROM clause separated by commas, the database engine first combine…

1.5.2

Join on Two Tables

A database is rarely useful if you can only look at one table at a time. Real questions — like "What is the price of a white shirt?" — require data from two different tables.

Summary

- A Function is used to perform a particular task and return a value as a result. - Single row functions work on a single row to return a single value.

Exercises

CBSE Sample Papers

Questions from official CBSE sample papers.

+Show 20 questions20 questions
  1. Q1Which MySQL command helps to add a primary key constraint to any table that has already been created ? (A) UPDATE (B) INSERT INTO (C) ALTER…Preview
  2. Q2Which of the following clause cannot work with SELECT statement in MYSQL ? (A) FROM (B) INSERT INTO (C) WHERE (D) GROUP BYPreview
  3. Q3Write any two differences between UPDATE and ALTER TABLE commands of MySQL.Preview
  4. Q4Rupam created a MySQL table to store the details of Nobel prize winners. Help her to write the following MySQL queries : TABLE : NOBEL | Win…Preview
  5. Q5State whether the following statement is True or False : In SQL, an aggregate function returns multiple values for each column on which it i…Preview
  6. Q6Which of the following is the correct expanded form of DML ? (A) Device Management Language (B) Device Manipulation Language (C) Data Manage…Preview
  7. Q7State whether the following statement is True or False : The INSTR(string1, string2) function in SQL returns 0 if string2 is not present as…Preview
  8. Q8Q. 20 and Q. 21 are Assertion (A) and Reason (R) Type questions. Choose the correct option as : (A) Both (A) and (R) are True, and (R) corre…Preview
  9. Q9Define the following terms with respect to RDBMS : a. Domain b. TuplePreview
  10. Q10To remove the leading and trailing space from data values in a column of MySql Table, we use (A) Left ( ) (B) Right ( ) (C) Trim ( ) (D) Ltr…Preview
  11. Q11If the substring is not present in a string, the INSTR ( ) returns: (A) - 1 (B) 1 (C) NULL (D) 0Preview
  12. Q12Keshav has written the following query to find out the sum of bonus earned by the employees of WEST zone: SELECT zone, TOTAL (bonus) FROM em…Preview
  13. Q13Differentiate between COUNT ( ) and COURT (*) functions in MYSQL. Give suitable examples to support your answer.Preview
  14. Q14State whether the following statement is True or False: The MOD() function in SQL returns the quotient of division operation between two num…Preview
  15. Q15What is a Database Management System (DBMS)? Mention any two examples of DBMS.Preview
  16. Q16In CHAR(10) and VARCHAR(10), what does the number 10 indicate ?Preview
  17. Q17‘Employee’ table has a column named ‘CITY’ that stores city in which each employee resides. Write SQL query to display details of all rows e…Preview
  18. Q18Write SQL statement to add a column “COUNTRY” with data type and size as VARCHAR(70) to the existing table named “PLAYER”. Is it a DDL or DM…Preview
  19. Q19Consider the following table ‘Transporter’ that stores the order details about items to be transported. Table : TRANSPORTER | ORDERNO | DRIV…Preview
  20. Q20Consider the following tables PARTICIPANT and ACTIVITY and answer the questions that follow : Table : PARTICIPANT | ADMNO | NAME | HOUSE | A…Preview