Core9X
Log inSign up

MBOSE Class XII Informatics Practices · Chapter 1

Querying and SQL Functions

Opening soon

Learn to manage and question databases with SQL, including useful functions for numbers, text and dates.

15 lessons · 56 practice questions · unit "Database Query using SQL" carries 25 marks

See classes open nowLog inMBOSE Class XII opens to new students soon.

What this chapter covers

  • Database and RDBMS terms
  • Keys and constraints
  • DDL and DML commands
  • SELECT with WHERE, DISTINCT, BETWEEN, IN, LIKE, IS NULL, ORDER BY
  • Single-row functions — math (POWER, ROUND, MOD), string (UCASE, LCASE, MID/SUBSTRING/SUBSTR, LENGTH, LEFT, RIGHT, INSTR, LTRIM, RTRIM, TRIM, CONCAT), date (NOW, SYSDATE, DATE, MONTH, MONTHNAME, YEAR, DAY, DAYNAME)
  • Aggregate functions
  • GROUP BY and HAVING
  • UNION, INTERSECT, MINUS, Cartesian product
  • Joins

Key terms

RDBMS

Software that stores data in related tables

Degree

Number of columns (attributes) of a table

Cardinality

Number of rows (tuples) of a table

Primary key

Column that uniquely identifies each row

Foreign key

Column referring to the primary key of another table

Constraint

Rule on the values allowed in a column

DDL

Commands that define structure: CREATE, ALTER, DROP

DML

Commands that change data: INSERT, UPDATE, DELETE

Single-row function

Returns one result for each row

Aggregate function

Returns one result for a group of rows

GROUP BY

Clause that forms groups of rows with equal values

HAVING

Clause that filters groups

Important questions with answers

10 of the 56 questions on this chapter, solved.

  1. Question 1 · Multiple choice · 1 mark

    The degree of a table is the number of its

    • (a) columns
    • (b) rows
    • (c) keys
    • (d) databases

    Answer: (a) columns

    The number of rows is the cardinality.

  2. Question 2 · Multiple choice · 1 mark

    Rows that have no value in the column Fee are found with

    • (a) WHERE Fee = NULL
    • (b) WHERE Fee == NULL
    • (c) WHERE Fee IS NULL
    • (d) WHERE Fee NULL

    Answer: (c) WHERE Fee IS NULL

    NULL cannot be compared with =.

  3. Question 3 · Multiple choice · 1 mark

    Aggregate functions such as SUM() and AVG() ignore

    • (a) NULL values
    • (b) numbers
    • (c) the first row
    • (d) duplicate rows

    Answer: (a) NULL values

    Only COUNT(*) counts rows with NULLs.

  4. Question 4 · Multiple choice · 1 mark

    The Cartesian product of a 4-row table and a 5-row table has cardinality

    • (a) 9
    • (b) 1
    • (c) 20
    • (d) 45

    Answer: (c) 20

    Cardinalities multiply: 4 × 5.

  5. Question 5 · Assertion and reason · 1 mark

    Assertion (A): HAVING can contain aggregate functions.

    Reason (R): HAVING filters the groups after GROUP BY, when the aggregate values are known.

    • (a) Both A and R are true, and R is the correct explanation of A.
    • (b) Both A and R are true, but R is not the correct explanation of A.
    • (c) A is true, but R is false.
    • (d) A is false, but R is true.

    Answer: (a) Both A and R are true, and R is the correct explanation of A.

    Group totals exist only after grouping.

  6. Question 6 · Short answer · 2 marks

    What are the degree and cardinality of a table with 5 columns and 12 rows?

    Answer

    Degree 5, cardinality 12.

  7. Question 7 · Short answer · 2 marks

    What does the DISTINCT keyword do?

    Answer

    Removes duplicate values from the result.

  8. Question 8 · Short answer · 3 marks

    What is a Cartesian product? Give its degree and cardinality for tables of 3 × 4 and 2 × 5 (columns × rows).

    Answer

    Every row of one table paired with every row of the other; degree 3 + 2 = 5, cardinality 4 × 5 = 20.

  9. Question 9 · Long answer · 5 marks

    Explain the categories of SQL commands with examples.

    Answer

    Section 1.2; Section 8.2 (HSSLC 2024, Q8(a)).

  10. Question 10 · Long answer · 5 marks

    Explain aggregate functions, GROUP BY and HAVING with queries.

    Answer

    Section 1.5; Section 8.2 (HSSLC 2024, Q8(b) (second choice); HSSLC 2023, Q8(c)).

Study the whole chapter

15 step-by-step lessons, all 56 practice questions with hints, flashcards and mock tests for MBOSE Class XII Informatics Practices.

See classes open nowLog inMBOSE Class XII opens to new students soon.