DBMS Quick Revision Notes
DBMS Quick Revision Notes
Brief Overview
This note covering Database Systems was created from a 334-page PDF (download link). It walks you
through the core concepts of data vs. information, database vs. DBMS, data abstraction layers, ER modeling,
relational theory, normalization, indexing, and transaction management, giving you a solid foundation before
diving into any class or textbook.
Key Points
Understand the distinction between raw data, processed information, and how DBMS organizes
them.
Learn the three‑level schema architecture and the notions of data independence.
Master ER diagrams, relational mapping, and the full normalization hierarchy up to 5NF.
Get acquainted with indexing structures, B‑trees, and concurrency control mechanisms.
The diagram visualizes eight common data categories (Geographical, Cultural, Scientific, etc.), illustrating the
breadth of raw data that can later become information.
Binary streams are the fundamental “bits” that computers store as data.
🗂️ Database & DBMS
Database – a structured collection of data stored electronically for easy access, management, and
updates.
DBMS – software that provides efficient storage, retrieval, and management of data, ensuring safety,
integrity, concurrency, and support for querying/reporting.
Illustrates how databases organize data (cylinders) and present analytical results (pie chart).
Three stacked cylinders symbolise the layered functions of a DBMS.
⚖️ File System vs. DBMS (Feature Comparison)
Feature File System DBMS
Data Access Slower, unstructured queries Structured querying → faster
access
Data Isolation Separate files → isolation issues Integrated data → reduced
isolation
Data Integrity Prone to accidental alteration Built‑in integrity constraints
Atomicity Incomplete operations cause Transaction support ensures
inconsistency atomicity
Concurrent Access Anomalies from simultaneous Advanced concurrency control
edits
Physical Data Independence – modify internal schema (e.g., add index) without altering
conceptual schema.
Logical Data Independence – change conceptual schema (e.g., add/remove entity) without
impacting external schemas or applications.
📦 Instance & Schema
Instance – snapshot of the database at a specific moment (current data).
Schema – blueprint describing the logical structure, tables, attributes, and relationships.
📊 ER Modeling
🧩 ER Diagram Overview
Developed by Peter Chen (1976), the ER model visualizes real‑world entities and relationships for
database design.
Historical context of the ER model’s creator.
🏷️ Entity & Entity Set
Entity – a distinguishable object (concrete or abstract).
Entity Set – collection of entities sharing the same attributes; drawn as a rectangle.
🔗 Relationship / Association
An association among two or more entities (different or same entity set).
Shows entities like Bank, Branch, Customer, Account, Loan and their relationships.
University System
🧩 Armstrong’s Axioms
1. Reflexivity – if Y ⊆ X , then X → Y .
2. Augmentation – if X → Y , then XZ → Y Z .
3. Transitivity – if X → Y and $
Ternary Relationship – involves three entity sets (e.g., Teacher – Subject – Course association).
N‑ary Relationship – a relationship among n entity sets, where n can be any positive integer.
📊 Participation Constraints
Total Participation – every entity of the participating set must appear in the relationship.
These constraints are often visualized by double (total) or single (partial) lines connecting entity sets to the
relationship diamond.
Weak Entity Set – lacks a sufficient set of attributes for a primary key; identified by a partial key
(discriminator) together with the primary key of an owning strong entity. Represented by a double
rectangle in ER diagrams.
📦 Aggregation
Aggregation abstracts a relationship (or set of relationships) as a higher‑level entity, allowing complex
relationships to be treated as single units in the diagram.
Core Terminology
Domain – set of atomic permissible values for an attribute (often defined by a data type).
Relation (Table) – a set of tuples (rows).
Tuple – a single row/record.
Arity / Degree – number of attributes (columns) in a relation.
Cardinality – number of tuples (rows) in a relation instance.
📚 Normalization Overview
Normalization refines a database schema to eliminate redundancy and dependency anomalies. The hierarchy
of normal forms:
1. 1NF → 2NF → 3NF → BCNF → 4NF → 5NF
First Normal Form (1NF)
Each cell holds indivisible (atomic) values; no repeating groups or multivalued attributes.
🗂️ Keys Summary
Key Type Definition
Superkey Any attribute set whose closure determines all
attributes of the relation.
Candidate Key Minimal superkey (no proper subset is a superkey).
Primary Key One candidate key chosen by the DB administrator;
cannot contain NULLs.
Alternate Key Any candidate key not selected as the primary key.
Foreign Key Attribute(s) referencing the primary key of another
(or the same) table, enforcing referential integrity.
Composite Key Key consisting of multiple attributes.
Secondary Key Non‑primary key used to speed up searches; may
contain duplicate values.
Prime Attribute Attribute that belongs to any candidate key.
Maintenance cost: ordered files require re‑ordering on insert/delete, while unordered files have cheaper
maintenance but slower searches.
Index Structures
Index record = (Key, Block‑pointer).
Index files are much smaller than the main data file because they store only the indexed attribute
and a pointer to the block containing the full record.
Index Types
Index Level Examples
Single‑level Primary Index, Clustering Index, Secondary Index
Multilevel Simple multilevel, B‑tree, B+‑tree
Primary Index – built on the primary key of a sorted main file; sparse (one entry per block).
Clustering Index – index on a non‑primary key that determines the
📂 Indexing Structures
🔹 Clustered Indexing
Definition: The main file is ordered on non‑key attributes.
Number of entries in the index file = number of unique values of the indexed attribute.
Example of both sparse and dense indexing.
🔹 Secondary Indexing
Definition: An additional index file built on an attribute other than the primary key, often because
frequent queries target that attribute.
Note: Dense and sparse are not mutually exclusive; a file can exhibit both characteristics depending on the
attribute and implementation.
🌳 B‑Tree Fundamentals
📐 Definition & Properties
An m‑way search tree where every node (except possibly the root) obeys:
➕ Insertion Rules
1. Start with a single root (also a leaf) at level 0.
2. When a full leaf (contains m − 1 keys) receives another key, split it:
Middle key moves up to the parent.
Two new sibling nodes receive the remaining keys.
3. If the parent becomes full, it splits recursively, possibly propagating to the root.
4. Splitting the root creates a new level (tree height increases by 1).
🧩 Example Insertion (Order = 3)
Insert the sequence 5, 10, 12, 13, 14, 1, 2, 3, 4 into an empty B‑tree of order 3.
(Step‑by‑step tree evolution omitted – focus on the rule that each split promotes the median key.)
📌 Derived Operators
Operator Symbol Derived From
Join ⋈ Cartesian product + selection
Intersection ∩ Set difference: r ∩ s = r − (r − s)
Division ÷ Uses ×, −, and π
Assignment = Directly names the result of an
expression
📊 Operator Classification
Unary: σ, π, ρ (operate on one relation).
Binary: ∪, −, × (operate on two relations).
📐 Relational Schema
Relation schema R(A₁, A₂, …, Aₙ) consists of a name R and an ordered list of attributes.
📂 Fundamental RA Operations
🔽 Project (Vertical Selection)
π selects specific columns; returns a relation without the omitted attributes.
Minimum 1 column, maximum n − 1.
Syntax example: π customer_name (depositor).
🔽 Select (Horizontal Selection)
σ filters rows based on a predicate p.
🔁 Additional RA Constructs
🔄 Rename
ρ creates a new relation name (or renames attributes) for the result of an expression.
➗ Division
Used when querying “all X that are related to every Y in another set.
🛠️ SQL Primer
📖 Introduction
SQL (Structured Query Language) is a domain‑specific language for defining, manipulating, and
querying relational data.
Originated from relational algebra (procedural) and tuple relational calculus (non‑procedural).
📆 Evolution of Standards
SQL‑86, SQL‑89, SQL‑92, SQL‑99, SQL‑2003, SQL‑2006, SQL‑2008, SQL‑2011, SQL‑2016,
SQL‑2019, SQL‑2023.
Example
> **Join** – combines tuples from two relations based on a join condition.
A | B | C
---|---|---
1 | P | X
2 | Q | Y
3 | R | Y
|
| **Left Outer Join** | `R1 ⟕ R2` |
A | B | C
---|---|---
1 | P | NULL
2 | Q | X
3 | R | Y
|
| **Right Outer Join** | `R1 ⟖ R2` |
A | B | C
---|---|---
2 | Q | X
3 | R | Y
NULL | S | Z
|
| **Full Outer Join** | `R1 ⟗ R2` |
A | B | C
---|---|---
1 | P | NULL
2 | Q | X
3 | R | Y
NULL | S | Z
|
The tables illustrate how unmatched rows are padded with **NULL** in outer joins.
---
> **Alias** – a temporary name given to a table or column for the duration of a query.
```sql
SELECT account_number, balance * 1.06 AS total_balance
FROM account;
📊 Aggregate Functions
Functions that take a set of values and return a single summarised value.
Function Description
AVG Arithmetic mean of numeric values.
MIN Smallest value.
MAX Largest value.
SUM Total of numeric values.
COUNT Number of rows (or non‑NULL values).
COUNT(*) counts all tuples, including those with NULLs.
All aggregates except COUNT ignore NULL values.
Equivalence Check:
Both statements produce the same average when balance contains no NULLs.
📑 Ordering Tuples
The ORDER BY clause sorts the result set.
Escape Character
-- Treat % as a literal character
SELECT *
FROM table_name
WHERE column_name LIKE 'ab\%cd%' ESCAPE '\';
⏰ Triggers
Trigger – a special procedure that fires automatically in response to INSERT, UPDATE, or DELETE
operations on a table or view.
📐 Relational Calculus
Tuple Relational Calculus (TRC)
Non‑procedural language; queries specify what to retrieve.
Property Meaning
Atomicity All operations succeed or none do.
Consistency Transaction transforms the database from one
consistent state to another.
Isolation Concurrent transactions appear to execute serially.
Durability Once committed, changes survive crashes.
Transaction States
State Description
ACTIVE Transaction is executing.
PARTIALLY COMMITTED Final statement executed; still pending write‑ahead
log flush.
FAILED Encountered an error; cannot continue.
ABORTED Rolled back; database restored to pre‑transaction
state.
COMMITTED Successfully completed; changes made durable.
Types of Schedules
Type Description
Serial Transactions run one after another; always safe.
Non‑Serial Operations interleaved; may be safe if serializable.
Conflict Serializability
Two operations conflict if they belong to different transactions, access the same data item, and at
least one is a WRITE.
A schedule is conflict‑serializable if it can be transformed into a serial schedule by swapping
non‑conflicting operations.
📜 Log‑Based Recovery
The transaction log records all actions to ensure durability and enable rollback.
Log Record Meaning
Transaction Ti begins.
Ti changes data item Xj from V1 to V2.
Ti successfully commits.
Ti is aborted (rolled back).
A write‑ahead log must be flushed before the actual data page is updated.
Data replication – copies of the same data item are kept at several sites.
Advantages Disadvantages
• Increased availability (fail‑over possible) • Higher storage costs
• Improved performance for read‑heavy • Greater maintenance complexity
workloads
• Enhanced reliability (fault tolerance) • Write operations become more complex
(need to keep copies consistent)
Data fragmentation – a relation is divided into smaller pieces (fragments) that are stored at
different sites.
Advantages Disadvantages
• Faster local data access (queries can be • Added complexity in design and
processed where the data reside) management
• Enables distributed processing and load • Strong network dependency for
balancing reconstruction
• Supports localized administration • Reconstruction of the original relation may
(site‑specific policies) be costly
Hybrid (mixed) fragmentation – combines horizontal and vertical fragmentation to exploit the
benefits of both. It is useful when access patterns are heterogeneous, providing better
performance for complex queries.
Because no later transaction can read a value that will never be produced, ignoring such writes
increases concurrency and can yield view‑serializable schedules that are not conflict‑serializable.
🔒 Lock‑Based Protocols
Lock modes
Mode Symbol Capability
Shared S Multiple transactions may read
simultaneously; no writes.
Exclusive X Single transaction may read &
write; blocks all other accesses.
Lock‑compatibility matrix
Requested \ Held S X
S ✔︎ (compatible) ✖︎
X ✖︎ ✖︎
A transaction must obtain the appropriate lock before accessing a data item.
If the requested lock conflicts with an existing lock, the request is delayed until the conflicting lock
is released.
Graph‑based vs. Validation‑based protocols
Graph‑based: builds a precedence graph of lock requests; does not guarantee serializability on its
own.
Validation‑based: suitable when most transactions are read‑only; validates a transaction after its
read phase before committing writes (see Section “Validation‑Based Protocol”).
🔄 Two‑Phase Locking (2PL) & Variants
Basic 2PL
Two‑Phase Locking – each transaction goes through a growing phase (acquires locks, no releases)
followed by a shrinking phase (releases locks, no new acquisitions).
Conservative ✔︎ ✔︎ ✖︎ ✖︎ ✖︎
2PL
Rigorous 2PL ✔︎ ✔︎ ✔︎ ✔︎ ✖︎
Strict 2PL ✔︎ ✔︎ ✔︎ ✔︎ ✖︎
Thomas Write ✖︎ ✔︎ ✖︎ ✔︎ ✔︎
Rule
Compatibility matrix
Requested \ Held IS IX S X
IS ✔︎ ✔︎ ✔︎ ✖︎
IX ✔︎ ✔︎ ✖︎ ✖︎
S ✔︎ ✖︎ ✔︎ ✖︎
X ✖︎ ✖︎ ✖︎ ✖︎
A transaction must acquire intention locks on all ancestors of the data item before obtaining the
final S or X lock on the item itself.
📋 Validation‑Based Protocol
Validation‑based concurrency control is effective when most transactions are read‑only, reducing
overhead compared to lock‑based schemes.
Execution phases
1. Read phase – transaction Ti reads required data items and writes updates to private (temporary)
variables; the database remains unchanged.
2. Validation phase – the system checks whether committing Ti would violate serializability (typically
by examining overlapping read/write sets of concurrent transactions).
If the test fails, Ti is aborted.
3. Write phase – for transactions that pass validation, the temporary updates are applied to the
database atomically.
Read‑only transactions skip this phase.
The protocol minimizes locking overhead and is especially suitable for environments with a high
proportion of read‑only workloads.