UNIT 3: DATABASE MANAGEMENT SYSTEM - EXAM-FOCUSED SHORT NOTES
3.1 DATABASE FUNDAMENTALS & ARCHITECTURE
File System vs. DBMS
| Aspect | File System | DBMS |
|---|---|---|
| Data Redundancy | High (duplicate files) | Low (centralized control) |
| Data Independence | Not supported | Logical & Physical independence |
| Concurrent Access | Limited, prone to inconsistencies | Controlled via locking/transactions |
| Backup & Recovery | Application-level, error-prone | Automated (logs, checkpoints) |
| Integrity Constraints | Application-enforced, inconsistent | Declarative (PRIMARY KEY, FOREIGN KEY, etc.) |
| Query Processing | No optimized query engine | Advanced optimizer, relational algebra/calculus |
| Security | File-level permissions | Fine-grained (user/role-based access control) |
[!TIP] Exam Focus: Always contrast data independence (DBMS strength) vs. tight coupling (file system weakness). Mention ACID as a DBMS-specific guarantee.
Three-Level Architecture (ANSI/SPARC)
-
External Level (View Level): User-specific views. Example: Clerk sees only
Emp(Dept, Salary). -
Conceptual Level (Logical Level): Entire database structure (entities, relationships, constraints). One logical schema for all users.
-
Internal Level (Physical Level): Physical storage details (files, indexes, blocks).
Mappings:
-
External/Conceptual Mapping: Shields users from logical changes.
-
Conceptual/Internal Mapping: Shields logical design from physical changes.
Data Independence:
- Logical: Change conceptual schema (e.g., add
- Physical: Change storage structures (e.g., switch from heap to B+ tree) without affecting conceptual schema.
Schema, Instance, Intension & Extension
-
Schema (Intension): The structure (tables, columns, types, constraints). Stable.
-
Instance (Extension): The actual data stored at a moment. Dynamic.
Example:
Student(Roll_no INT, Name VARCHAR(50))is the schema. The current set of student records is the instance.
Components of DBMS
-
Storage Manager: Handles file organization, indexing, buffer management.
-
Query Processor: Parses SQL, generates relational algebra, optimizes & executes.
-
Transaction Manager: Concurrency control (locking, timestamp), recovery (logs).
-
Authorization & Integrity Manager: Enforces constraints, user privileges.
-
Buffer Manager: Caches disk pages in main memory (critical for performance).
Functions of Database Administrator (DBA)
-
Schema Definition: Create/modify tables, indexes.
-
Storage & Parameter Tuning: Configure memory, file sizes.
-
Authorization & Security: Grant/revoke user access.
-
Integrity Constraint Specification: Define PRIMARY/FOREIGN keys, CHECK.
-
Backup & Recovery: Schedule backups, monitor logs.
-
Performance Monitoring: Tune queries, indexes.
3.2 DATA MODELING & ENTITY-RELATIONSHIP (ER) DESIGN
ER Model Fundamentals
| Concept | Symbol | Description |
|---|---|---|
| Entity | Rectangle | Real-world object (e.g., Student, Course). |
| Attribute | Ellipse | Property of entity. Types: Simple (atomic), Composite (e.g., Address), Multi-valued (e.g., Phone_No), Derived (Age from DOB). |
| Relationship | Diamond | Association between entities (e.g., Enrolls). Degree: # of entities (binary, ternary). Cardinality: 1:1, 1:N, M:N. |
| Participation | Line | Total (double line): Every entity must participate. Partial (single line): Optional. |
[!TIP] Exam Tip: In ER diagrams, multi-valued attributes are shown with double ellipses. Derived attributes are shown with dashed ellipses.
Advanced ER Constructs
-
Weak Entity Set: Lacks a primary key. Existence depends on owner entity. Identified by partial key + owner's key. Represented by double rectangle & identifying relationship (double diamond).
- Example:
Dependent(EmpID, Name, DOB)whereEmpIDis foreign key fromEmployee.
- Example:
-
Generalization: Bottom-up. Subclasses → superclass ("is-a").
-
Specialization: Top-down. Superclass → subclasses. Can be total/partial, disjoint/overlapping.
-
Aggregation: Relationship between a relationship and an entity (treated as a higher-level entity). Shown by a diamond surrounding a diamond.
Mapping ER to Relational Schema
| ER Construct | Relational Mapping Rule |
|---|---|
| Strong Entity | Create table with all simple/composite attributes. Primary key = entity's key. |
| Weak Entity | Create table with owner's PK + partial key. PK = (owner PK, partial key). |
| 1:1 Relationship | Merge into one table (prefer the one with total participation) or add FK to either side. |
| 1:N Relationship | Add FK (N-side) referencing PK (1-side). |
| M:N Relationship | Create new table with FKs from both sides. PK = combination of FKs. |
| Multi-valued Attribute | Create separate table: (Owner PK, Attribute). |
| Generalization/Specialization | Option 1: One table for superclass + all attributes (discriminator column).<br>Option 2: Separate table for each subclass (includes superclass PK).<br>Option 3: One table for all classes (many NULLs). |
3.3 RELATIONAL MODEL & RELATIONAL ALGEBRA/CALCULUS
Relational Model Concepts
-
Relation Schema:
R(A₁: D₁, A₂: D₂, ..., Aₙ: Dₙ)whereDᵢis domain. -
Relation Instance: Set of tuples at a moment. No duplicate tuples.
-
Keys:
-
Super Key: Any set of attributes uniquely identifying tuples.
-
Candidate Key: Minimal super key.
-
Primary Key: Chosen candidate key.
-
Foreign Key: Attribute(s) in R referencing PK of S. Enforces referential integrity.
-
Composite Key: Key with multiple attributes.
-
Referential Integrity: If
t[R.FK]exists, then∃ s[S.PK]such thatt[R.FK] = s[S.PK]. Actions:CASCADE,SET NULL,RESTRICT.
Relational Algebra Operations
Fundamental (6):
-
Select (σ):
σ_{condition}(R)→ Horizontal subset. -
Project (π):
π_{A₁, A₂}(R)→ Vertical subset (eliminates duplicates). -
Union (∪):
R ∪ S(R and S must be union-compatible). -
Set Difference (-):
R - S. -
Cartesian Product (×):
R × S. -
Rename (ρ):
ρ_{new}(R).
Additional:
-
Set Intersection (∩):
R ∩ S = R - (R - S). -
Natural Join (⋈):
R ⋈ S(equality on common attributes, removes duplicates). -
Division (÷):
R ÷ Sfinds tuples in R that match all tuples in S on common attributes.- Use case: "Find students who have taken all courses."
-
Outer Joins:
-
Left Outer Join (⟕): All tuples from left, matched from right (NULL if no match).
-
Right Outer Join (⟖): All from right.
-
Full Outer Join (⟗): All from both.
-
[!TIP] Expression Tree: Draw trees for complex queries. Selection (σ) and Projection (π) are pushed down early for optimization.
Relational Calculus
-
Tuple Relational Calculus (TRC):
{ t | P(t) }wheretis a tuple variable. Non-procedural.- Example:
{ t.Name | ∃s ∈ Student (s.Roll_no = t.Roll_no ∧ s.Dept = 'CS') }
- Example:
-
Domain Relational Calculus (DRC):
{ <x₁, x₂, ...> | P(x₁, x₂, ...) }wherexᵢare domain variables.- Example:
{ <n> | ∃r, d (Student(r, n, d) ∧ d = 'CS') }
- Example:
-
Codd's Theorem: Relational Algebra and Relational Calculus have equal expressive power.
3.4 SQL & QUERY FORMULATION
DDL Commands
CREATE TABLE Student (
Roll_no INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Dept VARCHAR(20),
Year INT CHECK (Year BETWEEN 1 AND 4)
);
ALTER TABLE Student ADD COLUMN Email VARCHAR(100);
ALTER TABLE Student DROP COLUMN Year;
ALTER TABLE Student MODIFY Dept VARCHAR(30);
DROP TABLE Student;
DML: SELECT Query Structure
SELECT [DISTINCT] <attribute-list>
FROM <table-list>
WHERE <condition>
GROUP BY <group-attributes>
HAVING <group-condition>
ORDER BY <attribute> [ASC|DESC];
-
WHEREfilters rows before grouping. -
GROUP BYcreates groups. -
HAVINGfilters groups. -
ORDER BYsorts final result.
Special Operators
-
LIKE: Pattern matching (%= any string,_= single char).WHERE Name LIKE 'A%' -
IN/NOT IN:WHERE Dept IN ('CS', 'IT') -
EXISTS/NOT EXISTS: Efficient for correlated subqueries.SELECT Name FROM Student S WHERE EXISTS ( SELECT * FROM Enrolls E WHERE E.Roll_no = S.Roll_no AND E.Course = 'DBMS' ); -
ANY/ALL: Compare with a set.Salary > ANY (SELECT Salary FROM Prof).
Aggregate Functions
| Function | Description | NULL Handling |
|---|---|---|
COUNT(*) |
Count all rows | Counts all rows |
COUNT(attr) |
Count non-NULL values | Ignores NULLs |
SUM(attr) |
Sum of values | Ignores NULLs |
AVG(attr) |
Average | Ignores NULLs |
MIN/MAX |
Minimum/Maximum | Ignores NULLs (if any) |
GROUP BY Rule: All non-aggregated attributes in
SELECTmust be inGROUP BY.
Joins in SQL
-- Inner Join (Equi/Theta)
SELECT * FROM Student S JOIN Enrolls E ON S.Roll_no = E.Roll_no;
-- Left Outer Join
SELECT * FROM Student S LEFT JOIN Enrolls E ON S.Roll_no = E.Roll_no;
-- Self Join (e.g., Employee hierarchy)
SELECT E1.Name, E2.Name AS Manager
FROM Employee E1 LEFT JOIN Employee E2 ON E1.MgrID = E2.EmpID;
-- Full Outer Join (Not in MySQL, use UNION)
SELECT * FROM S LEFT JOIN E ON ...
UNION
SELECT * FROM S RIGHT JOIN E ON ...;
Views
-
Virtual View:
CREATE VIEW CS_Students AS SELECT * FROM Student WHERE Dept='CS';(Stored query, no data storage). -
Materialized View: Physically stores result. Needs
REFRESH. Faster query, slower updates. -
Updatable Views: Simple (single table, no aggregates, no DISTINCT). Complex views require
INSTEAD OFtriggers.
Triggers
CREATE TRIGGER UpdateTotal
AFTER INSERT ON OrderItems
FOR EACH ROW
BEGIN
UPDATE Orders
SET Total_Amount = Total_Amount + NEW.Quantity * NEW.Price
WHERE OrderID = NEW.OrderID;
END;
-
Timing:
BEFORE/AFTER. -
Event:
INSERT/UPDATE/DELETE. -
Scope:
FOR EACH ROW(row-level) orFOR EACH STATEMENT.
3.5 DATABASE DESIGN & NORMALIZATION
Functional Dependencies (FDs)
-
Definition:
X → Ymeans value of X functionally determines value of Y in relation R. -
Trivial FD:
Y ⊆ X(e.g.,AB → A). Non-trivial:Y ⊈ X. -
Armstrong's Axioms:
-
Reflexivity: If
Y ⊆ X, thenX → Y. -
Augmentation: If
X → Y, thenXZ → YZ. -
Transitivity: If
X → YandY → Z, thenX → Z.
-
Additional Rules:
-
Union:
X → YandX → Z⇒X → YZ. -
Decomposition:
X → YZ⇒X → YandX → Z. -
Pseudotransitivity:
X → YandYZ → W⇒XZ → W.
-
-
Attribute Closure (X⁺)
Algorithm to find all attributes functionally determined by X.
-
Start:
result = X -
Repeat: For each FD
Y → Zin F, ifY ⊆ result, thenresult = result ∪ Z -
Until no change.
Uses: Find candidate keys (X⁺ = all attributes), check if FD
X → Ais implied (ifA ∈ X⁺).
Canonical/Minimal Cover
-
Decompose RHS of each FD to single attribute.
-
Remove extraneous LHS attributes (test if
(X - A)⁺under F contains A). -
Remove redundant FDs (test if FD is implied by others).
Normal Forms & Anomalies
| Normal Form | Condition | Anomalies Eliminated |
|---|---|---|
| 1NF | Atomic domains (no repeating groups). | None (basic structure). |
| 2NF | 1NF + No partial dependency of non-prime attribute on proper subset of candidate key. | Insert/Delete/Update anomalies due to partial dependencies. |
| 3NF | 2NF + No transitive dependency of non-prime attribute on candidate key (via another non-prime). | Anomalies due to transitive dependencies. |
| BCNF | For every non-trivial FD X → A, X must be a superkey. |
3NF does not cover all cases (e.g., AB → C, C → B). |
Steps to 3NF/BCNF Decomposition:
-
Find minimal cover F.
-
For each FD
X → Ain F, create relationRᵢ = X ∪ A. -
If no relation contains a candidate key of R, create one.
-
BCNF Check: If any relation violates BCNF (
X → Abut X not superkey), decompose that relation onX → A.
Lossless Join Condition: Decomposition
{R₁, R₂}of R is lossless iff(R₁ ∩ R₂) → R₁or(R₁ ∩ R₂) → R₂holds in F⁺.
Dependency Preserving: Decomposition is dependency preserving if F⁺ = (F₁ ∪ F₂ ∪ ...)⁺ where Fᵢ are FDs on Rᵢ.
4NF & Multi-valued Dependencies (MVD)
-
MVD:
X ↠ Ymeans for one X value, there is a set of independent Y values. (Notation: double arrow). -
4NF: For every non-trivial MVD
X ↠ Y, X must be a superkey. -
Example:
Student(Roll_no, Course, Hobby). If hobbies independent of courses,Roll_no ↠ CourseandRoll_no ↠ Hobby. IfRoll_nois key, it's 4NF. If not, decompose.
3.6 TRANSACTION MANAGEMENT
Transaction & States
-
Transaction (T): Logical unit of work (sequence of read/write operations). Must be atomic.
-
States:
Active → Partially Committed → Committed ↓ Failed → Aborted (→ Rollback → Active)State Diagram: Active (executing) → Partially Committed (end, before commit) → Committed. Any failure → Failed → Aborted → Rollback → Active (restart).
ACID Properties
| Property | Definition | Example |
|---|---|---|
| Atomicity | All-or-nothing. Either all operations executed or none. | Transfer: A=A-1000, B=B+1000. Both must succeed or both undone. |
| Consistency | Transaction takes DB from one valid state to another. Preserves integrity. | If A >= 1000 before, must be A >= 0 after. |
| Isolation | Concurrent transactions do not interfere. Equivalent to some serial order. | T1 reading A while T2 updating A → Dirty/Non-repeatable reads. |
| Durability | Once committed, changes survive system crash. | Logs flushed to disk before commit returns. |
Schedules & Serializability
-
Schedule: Order of operations from multiple transactions.
-
Serial Schedule: Transactions execute one after another. Always conflict-serializable.
-
Non-serial Schedule: Transactions interleaved. May be serializable (equivalent to some serial order).
-
Conflict Serializability:
-
Conflicting Operations: From different T, access same item, at least one is write.
-
Precedence Graph: Nodes = T. Edge
Tᵢ → TⱼifTᵢ's op conflicts with earlierTⱼ's op. -
Test: Schedule is conflict-serializable iff precedence graph is acyclic.
-
-
View Serializability: More general. Requires:
-
Same initial reads.
-
Same final writes.
-
Same read-from relationships.
-
Recovery (Log-Based)
-
Write-Ahead Logging (WAL): Before modifying a page, log record
(T, X, old, new)must be on disk. -
Log Record Types:
BEGIN,UPDATE(old, new),COMMIT,ABORT. -
Recovery Strategies:
-
Deferred Update: Apply changes to DB only at commit. Recovery: redo committed T.
-
Immediate Update: Apply changes immediately. Recovery: undo uncommitted T, redo committed T.
-
-
Checkpoint:
-
Flush all modified buffers to disk.
-
Write
<checkpoint L>to log, where L = list of active T at checkpoint. -
Recovery starts from last checkpoint. Only T in L (uncommitted at checkpoint) need undo; committed T after checkpoint need redo.
-
3.7 CONCURRENCY CONTROL
Problems in Concurrent Execution
| Problem | Description | Example |
|---|---|---|
| Lost Update | T1 reads X, T2 updates X, T1 updates X → T1's update lost. | Two clerks updating same account balance. |
| Dirty Read | T1 updates X, T2 reads X, T1 aborts → T2 reads uncommitted (dirty) data. | Reading temporary incorrect inventory level. |
| Unrepeatable Read | T1 reads X, T2 updates X, T1 reads X again → different values. | Checking price, price changes before buy. |
| Phantom Read | T1 reads set S (e.g., SELECT * WHERE salary>5000), T2 inserts new tuple into S, T1 reads S again → new tuple appears. |
New qualifying row appears in second read. |
Locking Protocols
-
Lock Modes:
-
Shared (S): Read lock. Multiple T can hold S-lock on same item.
-
Exclusive (X): Write lock. Only one T can hold X-lock.
-
-
Two-Phase Locking (2PL):
-
Growing Phase: T acquires locks (no release).
-
Shrinking Phase: T releases locks (no new acquires).
-
Guarantees Conflict Serializability.
-
Strict 2PL: All exclusive locks held until commit/abort. Prevents cascading aborts.
-
Cascadeless 2PL: S-locks released early, X-locks held until commit. Prevents dirty reads.
2PL is necessary but not sufficient for cascadeless/strict schedules. Strict 2PL ensures recoverable & cascadeless schedules.
-
Deadlock Management
-
Deadlock: Circular wait. T1 waits for T2, T2 waits for T1.
-
Prevention: Force one of Coffman conditions to fail.
-
Wait-Die: Older T waits, younger T aborts (uses timestamps).
-
Wound-Wait: Older T aborts younger T, younger T waits.
-
-
Avoidance: Wait-for Graph (WFG). If adding edge creates cycle → abort victim.
-
Detection & Resolution: Periodic WFG construction. If cycle → select victim (least cost to abort), rollback victim.
-
Blocking vs. Deadlock: Blocking is temporary (T waiting for lock held by active T). Deadlock is permanent circular wait.
Alternative Concurrency Control
-
Timestamp Ordering (TS):
-
Each T gets unique timestamp
TS(T). -
Each data item X has
RTS(X),WTS(X)(last read/write timestamp). -
Protocol: If T wants to read/write X:
-
If
TS(T) < WTS(X)→ abort (too old, overwritten). -
Else, allow & set
RTS(X)=TS(T)orWTS(X)=TS(T).
-
-
Thomas's Write Rule: Ignore outdated writes (
TS(T) < WTS(X)) instead of aborting (allows some non-serial schedules).
-
-
Optimistic (Validation-Based):
-
Phase 1 (Read): T reads & writes to private workspace.
-
Phase 2 (Validation): Check if T's reads conflict with earlier committed T. Three tests (serializable if passes).
-
Phase 3 (Write): If validated, write changes to DB; else abort.
-
Best for low-conflict workloads.
-
-
Multiple Granularity Locking (MGL):
-
Lock Hierarchy: Database → File → Page → Record.
-
Intention Locks: Indicate T intends to get S/X lock at lower level.
-
IS (Intention Shared): Will request S-lock on some descendant.
-
IX (Intention Exclusive): Will request X-lock on some descendant.
-
SIX (Shared + Intention Exclusive): S-lock on node, IX on descendants.
-
-
Compatibility Table: Governs which locks can coexist on same node.
-
3.8 QUERY PROCESSING & OPTIMIZATION
Steps in Query Processing
-
Parsing: Syntax check, build parse tree.
-
Translation: Parse tree → Relational Algebra expression tree.
-
Optimization: Choose lowest-cost evaluation plan.
-
Execution: Execute plan using algorithms (nested loops, hash join, etc.).
Query Optimization
-
Necessity: Exponential number of equivalent expressions. Small change → huge cost difference.
-
Heuristic Rules (Rule-Based):
-
Perform selection (
σ) as early as possible (reduces tuples). -
Perform projection (
π) as early as possible (reduces attributes). -
Combine cascading selections:
σ_{c1}(σ_{c2}(R))→σ_{c1∧c2}(R). -
Replace Cartesian Product + Selection with Join if possible.
-
Move projections down (but keep needed attributes for joins).
-
-
Cost-Based Optimization:
-
Cost Metrics: I/O cost (disk pages read/written), CPU cost (tuple comparisons), Memory cost, Network cost (distributed).
-
Statistics Needed:
nᵣ= # tuples in R,bᵣ= # pages in R,V(A, R)= # distinct values of A in R. -
Selectivity (sel): Fraction of tuples satisfying condition.
sel = 1 / max(V(A,R), 1)for equality. -
Cost Estimation: Use formulas for each operator (e.g., selection using index vs. full scan).
-
Operation Cost Comparison
| Operation | Cost (I/O) | Notes |
|---|---|---|
| Selection | With index: O(log_b N) (B+ tree) or O(1) (hash). Without: bᵣ. |
Clustering index better than secondary. |
| Projection | bᵣ (if no duplicate elimination). With π (eliminate dup): O(bᵣ log bᵣ). |
Duplicate elimination costly (sorting). |
| Join | Nested Loop: bᵣ + nᵣ * bₛ. Sort-Merge: bᵣ + bₛ + sort cost. Hash Join: 3(bᵣ + bₛ). |
Hash join often best for large, unsorted. |
| Sorting | External merge sort: 2 * bᵣ * log_{M-1}(bᵣ / M) where M = # buffer pages. |
Critical for GROUP BY, ORDER BY, merge join. |
3.9 STORAGE, INDEXING & FILE ORGANIZATION
File Organization Methods
| Method | Description | Advantages | Disadvantages |
|---|---|---|---|
| Heap File | Unordered. New records appended to end. | Fast insert. Simple. | Slow search/select (full scan). |
| Sorted File | Sorted on one key. | Fast range queries, binary search. | Slow insert (maintain order). |
| Hashed File | Hash function on key → bucket. | Direct access, O(1) for equality. | Slow range queries, collisions. |
Hashing Techniques
-
Static Hashing:
-
Buckets =
h(K) mod N. FixedN. -
Overflow: Chaining (linked list) or open addressing.
-
Problem: If N too small → long chains; if too large → wasted space.
-
-
Extendable Hashing:
-
Directory: Array of pointers to buckets. Size
2^d(global depthd). -
Local Depth: Per bucket. Split when bucket overflows.
-
Splitting: If bucket with local depth
loverflows, double directory ifl == d. Split bucket, redistribute records usingd+1bits. -
Advantage: Grows dynamically, minimal overflow.
-
-
Linear Hashing:
-
No directory. Buckets numbered 0,1,2,...
-
Split Round: When bucket
ioverflows, split it and create new bucket at end. Next split round: split bucket(i mod 2^r). -
Hash Functions:
h₀, h₁, h₂, .... Usehᵣafter2^rsplits.
-
Index Structures
-
Dense Index: Entry for every search key value (in data file). Faster search, larger index.
-
Sparse Index: Entry for each data block (only first key in block). Smaller index, requires data access for non-first keys.
-
Multi-level Index: Index on index. Top levels sparse, leaf level dense/sparse.
-
B⁺ Tree:
-
Structure: All leaves at same level. Internal nodes:
(P₁, K₁, P₂, K₂, ..., Pₙ)wherePᵢpointers,Kᵢkeys.nbetween⌈m/2⌉andm(order). -
Search: Start at root, follow pointers.
-
Insertion: Insert in leaf. If overflow → split leaf, propagate up (may increase height).
-
Deletion: Merge/redistribute. May decrease height.
-
Advantages: Balanced, supports range queries, efficient insert/delete.
-
Bitmap Indexing
-
For low-cardinality attributes (e.g.,
Gender,Marital_Status). -
Structure: One bit-vector per distinct value. Bit
i= 1 if tupleihas that value. -
Operations:
AND/OR→ bitwiseAND/OR. Fast for multiple conditions. -
Use Case: Data warehousing, OLAP queries with many
WHEREclauses on few distinct values.
RAID Levels
| Level | Description | Purpose | Trade-off |
|---|---|---|---|
| 0 | Striping (no redundancy) | Performance | No fault tolerance. |
| 1 | Mirroring (duplicate disks) | Reliability | 100% storage overhead. |
| 2 | Bit-level striping + Hamming code | Error correction | Complex, overhead. |
| 3 | Byte-level striping + dedicated parity disk | Performance + some redundancy | Parity disk bottleneck. |
| 4 | Block-level striping + dedicated parity disk | Better performance than 3 | Parity disk bottleneck. |
| 5 | Block-level striping + distributed parity | Balance performance/reliability | Parity calculation overhead. |
| 6 | Two independent parity schemes (P+Q) | High reliability | Very high overhead (2 parity disks). |
3.10 ADVANCED & SPECIAL TOPICS
Distributed Databases
-
Concepts:
-
Fragmentation: Horizontal (rows), Vertical (columns), Mixed.
-
Replication: Copy of fragment at multiple sites. Transparency: Users see single DB.
-
Allocation: Where fragments/replicas stored.
-
-
Challenges:
-
Distributed Query Processing: Minimize data transfer (semi-join, Bloom filter).
-
Distributed Transaction: 2PC (Two-Phase Commit) for atomicity across sites.
-
Concurrency Control: Distributed locking, timestamp with global coordinator.
-
Recovery: Logs at each site. Failure of coordinator/site complex.
-
NoSQL Databases
| Type | Data Model | Example | Use Case | CAP Preference |
|---|---|---|---|---|
| Key-Value | {key: value} |
Redis, DynamoDB | Caching, sessions | CP/AP |
| Document | JSON/BSON documents | MongoDB | Content management, catalogs | CP/AP |
| Column-Family | Column-oriented | Cassandra, HBase | Time-series, analytics | AP |
| Graph | Nodes + Edges | Neo4j | Social networks, recommendations | CP |
- Characteristics: Schema-flexible, horizontal scaling, BASE (Basic Availability, Soft state, Eventual consistency) vs. ACID.
Object-Oriented DBMS (OODBMS)
-
Concepts: Objects, Classes, Inheritance, Complex objects (nested), Methods.
-
vs. RDBMS:
| Feature | RDBMS | OODBMS | |-------------------|------------------------------------|-------------------------------------| | Data Model | Tables, rows, columns | Objects, classes | | Complex Data | Normalized, joins needed | Nested objects, direct references | | Inheritance | Not native (mapped to tables) | Native | | Schema | Fixed schema | Schema-flexible | | Query Language| SQL (declarative) | OQL (object-oriented) | | Use Case | Structured data, transactions | CAD, multimedia, complex hierarchies|
Miscellaneous Important Topics
-
Data Dictionary / System Catalog: Metadata repository (tables, columns, types, constraints, users, privileges). Queried via system tables (
INFORMATION_SCHEMAin SQL). -
Integrity Constraints:
-
Domain:
CHECK (age>0). -
Entity Integrity:
PRIMARY KEY NOT NULL. -
Referential Integrity:
FOREIGN KEY ... REFERENCES. -
User-defined:
ASSERTION(global),TRIGGER.
-
-
Assertions: Database-wide constraints.
CREATE ASSERTION chk_salary CHECK (NOT EXISTS (SELECT * FROM Employee WHERE Salary<0)); -
Web & Mobile Databases: Challenges: intermittent connectivity, security, synchronization, limited resources. Solutions: local storage (SQLite), sync frameworks.
-
Hierarchical Queries (Oracle
CONNECT BY):SELECT * FROM Employee START WITH ManagerID IS NULL CONNECT BY PRIOR EmpID = ManagerID; -
Oracle APEX: Low-code web development platform for Oracle DB. Builds apps on top of Oracle DB.
-
Complexity Measures: Query optimization cost model:
Cost = I/O_cost + CPU_cost + Network_cost. Often dominated by I/O (disk accesses).
Final Exam Strategy:
- Draw diagrams for ER, B+ Tree, State Diagram, Precedence Graph.
- Show step-by-step for normalization, closure, serializability test.
- Write SQL for all DDL/DML, especially joins, subqueries, aggregates.
- Compare & contrast (File System vs DBMS, 2PL vs Timestamp, OODBMS vs RDBMS).
- Define & explain with examples: ACID, FD, MVD, Anomalies, Views, Triggers.