Independent Preparation Bank for Pakistani Computing Graduates • 100% Free • No Signup
NSCTTest.
Simulator
All Articles
Home/Articles/Technical Guide
Technical Guide

Databases & SQL for NSCT: Normalization, Joins, Indexing & ACID Secrets

Databases represent 10% of your NSCT score. Review 1NF through BCNF, SQL JOIN nuances, B-Tree index structures, and transaction isolation levels.

NSCT Editorial & Syllabus Hub
Curated Technical Curriculum & Testing Benchmarks
7 min readNov 16, 2026Mock Exam

Databases & SQL for NSCT: Normalization, Joins, Indexing & ACID Secrets

Database knowledge is vital for every modern developer. In the NSCT, the Databases & SQL domain (10%) rigorously tests relational schema design, query evaluation order, transaction isolation, and indexing mechanics.


1. Normalization Breakdown (1NF to BCNF)

Normalization questions ask you to identify the highest normal form of a given table or select the decomposition that eliminates anomalies without losing dependencies.

  • 1NF (First Normal Form):
    • Each attribute must contain atomic (indivisible) values.
    • No repeating groups or multivalued attributes (e.g., storing comma-separated phone numbers violates 1NF).
  • 2NF (Second Normal Form):
    • Must be in 1NF.
    • No partial dependency: No non-prime attribute may depend on a proper subset of any candidate key. (Applies only when the candidate key is composite).
  • 3NF (Third Normal Form):
    • Must be in 2NF.
    • No transitive dependency: Non-prime attributes must not depend on other non-prime attributes ($X ightarrow Y$ requires $X$ to be a super key or $Y$ to be a prime attribute).
  • BCNF (Boyce-Codd Normal Form):
    • A stricter version of 3NF.
    • For every functional dependency $X ightarrow Y$, $X$ must be a super key.

2. SQL Logical Query Processing Order

A classic trap in NSCT is testing the order in which SQL evaluates clauses versus the order they are written:

  1. FROM & JOIN (Generates Cartesian product / join sets)
  2. WHERE (Filters rows before aggregation)
  3. GROUP BY (Collapses rows into groups)
  4. HAVING (Filters aggregated groups)
  5. SELECT (Computes projected expressions)
  6. DISTINCT (Removes duplicate tuples)
  7. ORDER BY (Sorts output rows)
  8. LIMIT / OFFSET (Restricts final row count)

Key Rule: You cannot use an alias declared in SELECT within the WHERE clause because WHERE executes before SELECT!


3. SQL JOIN Types & NULL Handling

  • INNER JOIN: Returns only matching rows from both tables.
  • LEFT (OUTER) JOIN: Returns all rows from left table; non-matching right columns become NULL.
  • RIGHT (OUTER) JOIN: Returns all rows from right table.
  • FULL OUTER JOIN: Returns all rows from both tables, filling NULL where match is missing.
  • CROSS JOIN: Cartesian product ($M imes N$ rows).

The Three-Valued Logic Trap

In SQL, comparison with NULL yields UNKNOWN, not TRUE or FALSE:

  • SELECT * FROM users WHERE salary = NULL; returns 0 rows (Always use IS NULL).
  • NOT (UNKNOWN) evaluates to UNKNOWN.

4. ACID Properties & Transaction Isolation Levels

  • Atomicity: All operations succeed, or the entire transaction is rolled back (Undo log).
  • Consistency: Database transitions from one valid state to another satisfying all integrity constraints.
  • Isolation: Concurrent transactions execute without cross-interference.
  • Durability: Committed changes persist even after server power failure (Write-Ahead Logging / Redo log).

The 4 ANSI SQL Isolation Levels

Isolation LevelDirty ReadNon-Repeatable ReadPhantom Read
Read UncommittedPossiblePossiblePossible
Read CommittedPreventedPossiblePossible
Repeatable ReadPreventedPreventedPossible (MySQL InnoDB prevents via MVCC)
SerializablePreventedPreventedPrevented

5. Indexing: B-Trees vs Hash Indexes

  • B+ Tree Index: Supports equality (=) and range queries (BETWEEN, <, >). Keys stored in balanced leaves linked sequentially.
  • Hash Index: $O(1)$ point lookups; cannot perform range scans or prefix searches (LIKE 'abc%').
Indexed Competency Concepts:
#Databases#SQL#ACID#Normalization#Indexing#Transactions
Official Standards Verification

Content structured in accordance with Higher Education Commission (HEC) Computing National Curriculum, PSEB TechLift competency standards, and the 120-minute Virtual University assessment model.