Circle of Learning Logo CIRCLE OF LEARNING Excellence in Education
CBSE Class 11 · Informatics Practices Chapter 4 Session 2026-27

Database Concepts and Structured Query Language (SQL) Formulas & Cheat Sheet

Complete chapter-wise reference, step-by-step formula explanations, structured table, and board exam trap warnings.

Core Concepts & Theoretical Foundations

  • Relational Database Concepts: Database (organized collection of interrelated data), Table / Relation (data organized in rows and columns), Attribute / Field (column), Tuple / Record (row), Domain (set of permissible values for an attribute).
  • Degree and Cardinality: Degree = Total number of attributes (columns); Cardinality = Total number of tuples (rows).
  • Keys in a Database: Candidate Key (minimal set of attributes identifying a tuple uniquely), Primary Key (selected candidate key, cannot be NULL), Alternate Key (candidate keys not chosen as primary), Foreign Key (attribute referencing primary key of another table).
  • Structured Query Language (SQL): Standard language for relational databases; DDL (Data Definition Language: `CREATE DATABASE`, `USE`, `CREATE TABLE`, `DROP TABLE`, `ALTER TABLE`) vs DML (Data Manipulation Language: `INSERT INTO`, `SELECT`, `UPDATE`, `DELETE`).
  • Data Types in MySQL: `CHAR(n)` (fixed length), `VARCHAR(n)` (variable length), `INT`, `DECIMAL(p, s)`, `DATE` ('YYYY-MM-DD').
  • Query Filtering & Sorting: `WHERE` clause, Comparison operators (`=`, `!=`, `<`, `>`, `<=`, `>=`), Logical operators (`AND`, `OR`, `NOT`), Special operators (`BETWEEN ... AND`, `IN (...)`, `LIKE` with wildcards `%` and `_`, `IS NULL`, `IS NOT NULL`), `ORDER BY` (ASC/DESC), `DISTINCT`.

Chapter Formulas & Equations (12 entries)

# Topic / Formula Name Mathematical Form & Equation Conditions, Meaning & Board Tips
1 Degree and Cardinality Definitions
Degree=Nattributes  (Columns),Cardinality=Ntuples  (Rows)\text{Degree} = N_{\text{attributes}} \; (\text{Columns}), \quad \text{Cardinality} = N_{\text{tuples}} \; (\text{Rows})

Adding a column increases Degree by 1; inserting a record increases Cardinality by 1.

2 Candidate Key, Primary Key, and Alternate Key Identity
Candidate Keys={Primary Key}∪Alternate Keys\text{Candidate Keys} = \{\text{Primary Key}\} \cup \text{Alternate Keys}

Primary key cannot contain NULL values and must uniquely identify every row (Entity Integrity).

3 DDL vs DML Command Classification
SQL=DDL (Defines Schema)  ∪  DML (Manipulates Rows)\text{SQL} = \text{DDL (Defines Schema)} \; \cup \; \text{DML (Manipulates Rows)}

DDL changes table schema/columns; DML modifies tuple values inside the existing schema.

4 SQL Pattern Matching Wildcards (LIKE Operator)
LIKE:{%Any sequence of 0 or more characters_Exactly one single character\text{LIKE}: \begin{cases} \% & \text{Any sequence of 0 or more characters} \\ \_ & \text{Exactly one single character} \end{cases}

e.g. 'A%' matches words starting with A; '_ _ _' matches strings of exactly 3 characters.

5 CHAR vs VARCHAR Storage Formula
Bytes(CHAR(n))=n,Bytes(VARCHAR(n))=len(s)+1\text{Bytes}(\text{CHAR}(n)) = n, \quad \text{Bytes}(\text{VARCHAR}(n)) = \text{len}(s) + 1

CHAR pads with trailing spaces; VARCHAR conserves disk storage for variable-length text.

6 NULL Value Relational Check
Check: col IS NULL[col=NULL evaluates to Unknown/False]\text{Check: } \text{col IS NULL} \quad [\text{col} = \text{NULL evaluates to Unknown/False}]

NULL represents missing, unavailable, or unassigned data, not zero or empty space.

7 BETWEEN ... AND Inclusive Range Rule
x∈[low,high]  ⟺  x≥low  ∧  x≤highx \in [\text{low}, \text{high}] \iff x \ge \text{low} \; \land \; x \le \text{high}

Includes values exactly equal to low and high boundaries.

8 Cartesian Product of Two Relations
Deg(R×S)=Deg(R)+Deg(S),Card(R×S)=Card(R)×Card(S)\text{Deg}(R \times S) = \text{Deg}(R) + \text{Deg}(S), \quad \text{Card}(R \times S) = \text{Card}(R) \times \text{Card}(S)

Combines every row of table R with every row of table S.

9 Foreign Key Referential Integrity Rule
FK∈ΠPK(Parent Table)  ∪  {NULL}\text{FK} \in \Pi_{\text{PK}}(\text{Parent Table}) \; \cup \; \{\text{NULL}\}

Prevents orphaned records in child tables when parent records are updated or deleted.

10 ORDER BY Sorting Precedence
ORDER BY c1  [ASC∣DESC],  c2  [ASC∣DESC]\text{ORDER BY } c_1 \; [\text{ASC}|\text{DESC}], \; c_2 \; [\text{ASC}|\text{DESC}]

Ties in col1 are broken by secondary sorting along col2.

11 DISTINCT Keyword Elimination
DISTINCT(S)={x∈S∣x unique}\text{DISTINCT}(S) = \{ x \in S \mid x \text{ unique} \}

Returns unique set of scalar values present across that attribute column.

12 UPDATE vs ALTER TABLE Distinction
UPDATE→Data in Rows,ALTER→Columns in Schema\text{UPDATE} \to \text{Data in Rows}, \quad \text{ALTER} \to \text{Columns in Schema}

Common board exam question testing DDL vs DML scope.

Key Scientific Diagrams & Concept Schematics: Database Concepts and Structured Query Language (SQL)

Visual Reference: rdbms-sql

Official NCERT board curriculum concept schematic and mathematical/scientific reference diagram.

CBSE Board Exam Tips & Frequent Pitfalls

  • In Degree and Cardinality questions: Degree = Columns (Attributes); Cardinality = Rows (Tuples). If a table has 4 columns and 10 rows, Degree = 4, Cardinality = 10.
  • Remember: To check for NULL values, use `IS NULL` or `IS NOT NULL`. Writing `= NULL` will fetch ZERO rows and score 0 marks!
  • In SQL pattern matching with LIKE: `%` represents any number of characters (including zero); `_` represents exactly ONE character.

Step-by-Step Worked Board Exam Examples

Example 1: A table 'STUDENT' has 5 columns and 20 rows. Another table 'SPORTS' has 3 columns and 8 rows. Find the Degree and Cardinality of their Cartesian Product (STUDENT x SPORTS).

Step 1: Degree of Cartesian Product = Degree(STUDENT) + Degree(SPORTS) = 5 + 3 = 8.

Step 2: Cardinality of Cartesian Product = Cardinality(STUDENT) * Cardinality(SPORTS) = 20 * 8 = 160.

Ans: Degree = 8, Cardinality = 160.

Example 2: Write an SQL query to display the Name and Salary of all employees from table 'EMP' whose salary is between 30000 and 50000 (inclusive) and whose name starts with letter 'S'.

Step 1: Target columns: `SELECT Name, Salary FROM EMP`.

Step 2: Salary condition: `Salary BETWEEN 30000 AND 50000` (or `Salary >= 30000 AND Salary <= 50000`).

Step 3: Name pattern condition: `Name LIKE 'S%'` (starts with S followed by any characters).

Step 4: Combine with AND: `SELECT Name, Salary FROM EMP WHERE Salary BETWEEN 30000 AND 50000 AND Name LIKE 'S%';`

Ans: SELECT Name, Salary FROM EMP WHERE Salary BETWEEN 30000 AND 50000 AND Name LIKE 'S%';

Common Mistakes to Avoid in Exam

  • Confusing Degree (columns) with Cardinality (rows).
  • Writing `WHERE Salary = NULL` instead of `WHERE Salary IS NULL`.
  • Confusing `ALTER TABLE` (DDL command to add/modify columns) with `UPDATE` (DML command to change cell values).

Target Practice Questions

Q1. Write the SQL command to delete all rows from table 'EMPLOYEE' without removing the table structure.

Correct Answer: DELETE FROM EMPLOYEE; (or TRUNCATE TABLE EMPLOYEE;).

Q2. What is an Alternate Key?

Correct Answer: Any Candidate Key that is not chosen as the Primary Key of a relation.

Q3. Write the clause used in SQL to display records in descending order of a column 'Marks'.

Correct Answer: ORDER BY Marks DESC.

Frequently Asked Questions

Q. What is a Primary Key and what are its two main constraints?

A Primary Key is an attribute or combination of attributes that uniquely identifies each tuple (row) in a relation. Its two mandatory constraints are: (1) It must be Unique (no two rows can have the same primary key value); (2) It cannot contain NULL values (Entity Integrity rule).

Q. What is the difference between DDL and DML commands in SQL?

DDL (Data Definition Language) commands (such as CREATE, ALTER, DROP) are used to define, alter, and delete the structure or schema of database objects. DML (Data Manipulation Language) commands (such as INSERT, SELECT, UPDATE, DELETE) are used to query and manipulate data tuples within the existing table structure.

Q. What is a Foreign Key?

A Foreign Key is an attribute in a child table whose values must match the Primary Key values of a referenced parent table (or be NULL). It enforces referential integrity between related tables in an RDBMS.

Q. What is the difference between CHAR and VARCHAR data types?

CHAR(n) is a fixed-length string data type that always consumes n bytes of storage regardless of actual text length, padding unused spaces with blanks. VARCHAR(n) is a variable-length string data type that allocates storage strictly proportional to the actual characters entered (plus 1 byte of length overhead).

← View All 5 Chapters in Class 11 Informatics Practices Formula Book