IT 220

Database Management System

TU BIM · Semester 4 · BIM curriculum effective from 2021

Requirement
required
Credits
3
Past papers
1 papers

Past exam papers

Complete papers are arranged by official model question paper.

past exam papers loaded.

Tribhuvan University

Faculty of Management

Office of the Dean

Official Model Question Paper / Dean's Office Blueprint

Course: IT 220 · Database Management System

Level: Bachelor of Information Management (BIM) · Semester 4

Full Marks: 60

Time: 3 hrs.

Candidates are required to give their answers in their own words as far as practicable. Figures in the margin indicate full marks.

Group A

Brief Answer Questions. Attempt ALL questions. (5 × 2 = 10)

[5*2=10]
  1. [2]

    Define data independence. Differentiate between physical and logical data independence.

    View model answerHide model answer

    Data Independence: Physical vs. Logical

    Data Independence is the architectural capacity to modify a database schema at one level of the three-schema architecture without having to alter the schemas at subsequent higher levels.

    • Physical Data Independence: The ability to alter the physical storage structure, file organization, or indexing mechanisms (internal schema) without altering the logical/conceptual schema or application programs.
    • Logical Data Independence: The ability to modify the conceptual schema (adding new attributes, splitting entities) without requiring changes to existing external views or user queries. Logical independence is substantially harder to achieve than physical independence.
  2. [2]

    What is a weak entity set? How is it visually designated in an Entity-Relationship (ER) diagram?

    View model answerHide model answer

    Weak Entity Set and ER Representation

    A Weak Entity Set is an entity set that does not possess sufficient key attributes to form its own primary key and depends existence-wise on a parent/identifying entity set.

    • Identifying Key (Discriminator): Its records are uniquely distinguished only when combined with the primary key of the owner entity.
    • ER Diagram Representation:
      • Weak entity set: Represented by a double rectangle.
      • Identifying relationship: Represented by a double diamond.
      • Partial discriminator key: Represented with a dashed underline inside the weak entity attribute oval.
  3. [2]

    State the strict condition required for a relational schema to be in Boyce-Codd Normal Form (BCNF).

    View model answerHide model answer

    Condition for Boyce-Codd Normal Form (BCNF)

    A relational schema RR is in Boyce-Codd Normal Form (BCNF) if and only if for every non-trivial functional dependency X→YX \rightarrow Y holding over RR:

    XX must be a superkey of relation RR.

    In other words, BCNF strictly eliminates all functional dependencies where the determinant (XX) is not a candidate key, thereby removing anomalies that can survive 3NF when overlapping candidate keys exist.

  4. [2]

    State the ACID properties in database transaction processing.

    View model answerHide model answer

    ACID Properties of Database Transactions

    1. Atomicity (All-or-Nothing): Guarantees that all operations within a transaction execute completely or none of them are reflected in the database.
    2. Consistency (Preservation of Invariants): Ensures the transaction transitions the database from one valid state satisfying all integrity constraints to another valid state.
    3. Isolation (Concurrent Independence): Guarantees that the intermediate states of concurrently executing transactions are invisible to one another.
    4. Durability (Persistence): Ensures that once a transaction commits, its state updates persist permanently in non-volatile storage, surviving subsequent system crashes.
  5. [2]

    Differentiate between DELETE and TRUNCATE statements in SQL.

    View model answerHide model answer

    DELETE vs. TRUNCATE in SQL

    Feature DELETE Statement TRUNCATE Statement
    Command Category Data Manipulation Language (DML). Data Definition Language (DDL).
    Filtering (WHERE) Supports WHERE clause to delete specific rows conditionally. Does not support WHERE; removes all rows from the table entirely.
    Row Deletion Mechanism Removes rows individually and logs each deleted tuple in transaction log. Deallocates complete data pages; minimal logging in transaction logs.
    Execution Performance Slower for large datasets due to row-by-row logging. Significantly faster as it clears data pages directly.
    Triggers Fires ON DELETE DML triggers. Does not invoke DML delete triggers.

Group B

Descriptive Answer Questions. Attempt any THREE questions. (3 × 10 = 30)

[3*10=30]
  1. [10]

    A university management portal tracks academic operations with the following specifications:\n- A Department has a unique DeptID, DeptName, and OfficeLocation.\n- A Professor has an EmployeeID, Name, Qualification, and works in exactly one Department. One professor chairs each department.\n- A Course has a CourseCode, CourseTitle, and Credits. A department offers multiple courses, but a course is offered by exactly one department.\n- A Student has a RollNo, FullName, and Semester. A student enrolls in multiple courses, and each course enrolls multiple students.\n\nRequired:\na. Construct an Entity-Relationship (ER) diagram showing entities, primary keys, relationships, and cardinality ratios\nb. Map the ER diagram into a normalized Relational Database Schema showing primary keys and foreign keys.

    View model answerHide model answer

    Entity-Relationship Modeling & Relational Schema Mapping

    a. Entity-Relationship (ER) Architecture

    • Entities & Attributes:
      • DEPARTMENT: {DeptID‾\underline{\text{DeptID}}, DeptName, OfficeLocation}
      • PROFESSOR: {EmployeeID‾\underline{\text{EmployeeID}}, Name, Qualification}
      • COURSE: {CourseCode‾\underline{\text{CourseCode}}, CourseTitle, Credits}
      • STUDENT: {RollNo‾\underline{\text{RollNo}}, FullName, Semester}
    • Relationships & Cardinalities:
      • Chairs (PROFESSOR to DEPARTMENT): 1:11:1 (One professor chairs one department).
      • Works_In (PROFESSOR to DEPARTMENT): N:1N:1 (Many professors belong to one department).
      • Offers (DEPARTMENT to COURSE): 1:N1:N (One department offers many courses).
      • Enrolls (STUDENT to COURSE): M:NM:N (Many students enroll in many courses; Relationship attribute: Grade, AcademicYear).

    b. Relational Schema Mapping

    1. DEPARTMENT (DeptID‾\underline{\text{DeptID}}, DeptName, OfficeLocation, ChairProfID*)
      • Foreign Key: ChairProfID references PROFESSOR(EmployeeID) (Unique).
    2. PROFESSOR (EmployeeID‾\underline{\text{EmployeeID}}, Name, Qualification, DeptID*)
      • Foreign Key: DeptID references DEPARTMENT(DeptID).
    3. COURSE (CourseCode‾\underline{\text{CourseCode}}, CourseTitle, Credits, DeptID*)
      • Foreign Key: DeptID references DEPARTMENT(DeptID).
    4. STUDENT (RollNo‾\underline{\text{RollNo}}, FullName, Semester)
    5. ENROLLMENT (RollNo*,CourseCode*‾\underline{\text{RollNo*}, \text{CourseCode*}}, AcademicYear, Grade)
      • Composite Primary Key: (RollNo, CourseCode)
      • Foreign Keys: RollNo references STUDENT(RollNo), CourseCode references COURSE(CourseCode).
  2. [10]

    Given the following enterprise relational database schema:\n- EMPLOYEE(EmpID, EmpName, Salary, DeptNo, JobTitle)\n- DEPARTMENT(DeptNo, DeptName, Location)\n- PROJECT(ProjNo, ProjName, Budget, DeptNo)\n- WORKS_ON(EmpID, ProjNo, HoursWorked)\n\nWrite SQL queries and Relational Algebra expressions for the following:\na. List the names and salaries of all employees who work in the ‘Kathmandu’ location.\nb. Find the project number and project name that has the highest budget.\nc. Find the names of employees who have worked on all projects managed by department number 10.\nd. Retrieve the department name and total salary expenditure for departments having more than 5 employees.\ne. Increase the salary by 10% for all employees working on the project titled ‘Core Banking Upgrade’.

    View model answerHide model answer

    Relational Algebra and SQL Queries

    a. Employees working in ‘Kathmandu’

    • Relational Algebra:
      ΠEmpName, Salary(EMPLOYEE⋈EMPLOYEE.DeptNo = DEPARTMENT.DeptNo(σLocation = ’Kathmandu’(DEPARTMENT)))\Pi_{\text{EmpName, Salary}} (\text{EMPLOYEE} \bowtie_{\text{EMPLOYEE.DeptNo = DEPARTMENT.DeptNo}} (\sigma_{\text{Location = 'Kathmandu'}} (\text{DEPARTMENT})))
    • SQL Query:
      SELECT E.EmpName, E.Salary
      FROM EMPLOYEE E
      JOIN DEPARTMENT D ON E.DeptNo = D.DeptNo
      WHERE D.Location = 'Kathmandu';
      

    b. Project with the highest budget

    • SQL Query:
      SELECT ProjNo, ProjName, Budget
      FROM PROJECT
      WHERE Budget = (SELECT MAX(Budget) FROM PROJECT);
      

    c. Employees working on all projects managed by Dept 10 (Relational Division)

    • Relational Algebra:
      ΠEmpID, ProjNo(WORKS_ON)÷ΠProjNo(σDeptNo = 10(PROJECT))\Pi_{\text{EmpID, ProjNo}}(\text{WORKS\_ON}) \div \Pi_{\text{ProjNo}}(\sigma_{\text{DeptNo = 10}}(\text{PROJECT}))
    • SQL Query:
      SELECT E.EmpName
      FROM EMPLOYEE E
      WHERE NOT EXISTS (
          SELECT P.ProjNo
          FROM PROJECT P
          WHERE P.DeptNo = 10
          EXCEPT
          SELECT W.ProjNo
          FROM WORKS_ON W
          WHERE W.EmpID = E.EmpID
      );
      

    d. Department Name and total salary for departments with > 5 employees

    • SQL Query:
      SELECT D.DeptName, SUM(E.Salary) AS TotalSalaryExpenditure
      FROM DEPARTMENT D
      JOIN EMPLOYEE E ON D.DeptNo = E.DeptNo
      GROUP BY D.DeptNo, D.DeptName
      HAVING COUNT(E.EmpID) > 5;
      

    e. Update salary by +10% for employees on ‘Core Banking Upgrade’

    • SQL Query:
      UPDATE EMPLOYEE
      SET Salary = Salary * 1.10
      WHERE EmpID IN (
          SELECT W.EmpID
          FROM WORKS_ON W
          JOIN PROJECT P ON W.ProjNo = P.ProjNo
          WHERE P.ProjName = 'Core Banking Upgrade'
      );
      
  3. [10]

    Consider a relation schema R(A,B,C,D,E,G)R(A, B, C, D, E, G) with the following set of functional dependencies:\nF={A→B,  BC→D,  D→E,  E→G,  G→A}F = \{ A \rightarrow B,\; BC \rightarrow D,\; D \rightarrow E,\; E \rightarrow G,\; G \rightarrow A \}\n\nRequired:\na. Find all candidate keys of relation RR.\nb. Determine the highest normal form of relation RR.\nc. Decompose RR step-by-step into 3NF and BCNF, ensuring lossless join and dependency preservation.

    View model answerHide model answer

    Database Normalization Analysis

    a. Finding Candidate Keys

    Compute attribute closures using FF:

    1. Closure of (A,C)(A, C):
      • (AC)+={A,C}(AC)^+ = \{A, C\}
      • A→B  ⟹  {A,B,C}A \rightarrow B \implies \{A, B, C\}
      • BC→D  ⟹  {A,B,C,D}BC \rightarrow D \implies \{A, B, C, D\}
      • D→E  ⟹  {A,B,C,D,E}D \rightarrow E \implies \{A, B, C, D, E\}
      • E→G  ⟹  {A,B,C,D,E,G}=RE \rightarrow G \implies \{A, B, C, D, E, G\} = R
      • Thus, (A,C)(A, C) is a candidate key.
    2. From G→AG \rightarrow A: Closure of (G,C)+={G,C,A,B,D,E}=R(G, C)^+ = \{G, C, A, B, D, E\} = R. Thus (G,C)(G, C) is a candidate key.
    3. From E→GE \rightarrow G: Closure of (E,C)+=R(E, C)^+ = R. Thus (E,C)(E, C) is a candidate key.
    4. From D→ED \rightarrow E: Closure of (D,C)+=R(D, C)^+ = R. Thus (D,C)(D, C) is a candidate key.
    5. From BC→DBC \rightarrow D: Closure of (B,C)+=R(B, C)^+ = R. Thus (B,C)(B, C) is a candidate key.

    Prime Attributes: {A,B,C,D,E,G}\{A, B, C, D, E, G\} (Every attribute is a member of at least one candidate key).

    b. Determining Highest Normal Form

    • 1NF: Satisfied (atomic attributes).
    • 2NF: A relation is in 2NF if no non-prime attribute is partially dependent on any candidate key. Since all attributes in RR are prime attributes, there are no non-prime attributes. Therefore, RR is in 2NF.
    • 3NF: For every X→YX \rightarrow Y, either XX is a superkey OR YY is a prime attribute.
      • In A→BA \rightarrow B: AA is not a superkey, but BB is a prime attribute (holds!).
      • In D→ED \rightarrow E: DD is not a superkey, but EE is prime (holds!).
      • In E→GE \rightarrow G: EE is not a superkey, but GG is prime (holds!).
      • In G→AG \rightarrow A: GG is not a superkey, but AA is prime (holds!).
      • Therefore, RR is in 3NF.
    • BCNF: Requires XX to be a superkey for every non-trivial X→YX \rightarrow Y. In A→BA \rightarrow B, AA is not a superkey (closure of AA is {A,B}≠R\{A, B\} \neq R). Hence, RR is NOT in BCNF.
    • Highest Normal Form: 3NF.

    c. Decomposing into BCNF

    To eliminate violations of BCNF:

    1. Identify violating dependency: A→BA \rightarrow B (A+={A,B}A^+ = \{A, B\}).
      • Decompose RR into R1(A,B)R_1(A, B) with candidate key AA.
      • Remaining relation: R2(A,C,D,E,G)R_2(A, C, D, E, G).
    2. In R2R_2, candidate keys are (A,C),(D,C),(E,C),(G,C)(A, C), (D, C), (E, C), (G, C).
      • Dependencies holding in R2R_2: AC→D,D→E,E→G,G→AAC \rightarrow D, D \rightarrow E, E \rightarrow G, G \rightarrow A.
      • D→ED \rightarrow E violates BCNF (DD is not a superkey of R2R_2).
      • Decompose R2R_2 into R21(D,E)R_{21}(D, E) and R22(A,C,D,G)R_{22}(A, C, D, G).
    3. In R22R_{22}, G→AG \rightarrow A violates BCNF.
      • Decompose into R221(G,A)R_{221}(G, A) and R222(C,D,G)R_{222}(C, D, G).
    4. In R222R_{222}, D→GD \rightarrow G (via D→E→GD \rightarrow E \rightarrow G).
      • Decompose into R2221(D,G)R_{2221}(D, G) and R2222(C,D)R_{2222}(C, D).

    Final BCNF Relations:

    • R1(A,B)R_1(A, B), R2(D,E)R_2(D, E), R3(E,G)R_3(E, G), R4(G,A)R_4(G, A), R5(B,C,D)R_5(B, C, D). This decomposition is strictly lossless.
  4. [10]

    Explain the Two-Phase Locking (2PL) protocol in database concurrency control.\na. Differentiate between basic 2PL, conservative 2PL, and strict 2PL.\nb. How does Strict 2PL prevent cascading aborts?\nc. Explain the write-ahead logging (WAL) rule and contrast deferred update vs. immediate update recovery techniques.

    View model answerHide model answer

    Concurrency Control and Database Recovery Techniques

    a. Two-Phase Locking (2PL) Protocols

    The 2PL protocol guarantees serializability of concurrent execution schedules by dividing transaction lock management into two distinct phases:

    1. Growing Phase: The transaction may obtain new locks (shared or exclusive) but cannot release any lock.
    2. Shrinking Phase: The transaction may release locks but cannot acquire any new locks.

    Variations of 2PL:

    • Basic 2PL: Locks are acquired as needed during execution and released gradually once the lock point is reached. Susceptible to cascading rollbacks and deadlocks.
    • Conservative (Static) 2PL: The transaction predeclares and locks all required data items simultaneously before commencing execution. Prevents deadlocks completely, but reduces concurrency.
    • Strict 2PL: All exclusive (write) locks acquired by a transaction are held until the transaction explicitly commits or aborts.
    • Rigorous 2PL: Both shared (read) and exclusive (write) locks are held until transaction commit/abort.

    b. Prevention of Cascading Aborts by Strict 2PL

    A cascading abort occurs when transaction T1T_1 writes an uncommitted value to item XX, transaction T2T_2 reads that dirty value of XX, and subsequent failure of T1T_1 forces T2T_2 to abort as well. In Strict 2PL, transaction T1T_1 never releases its exclusive lock on XX until its commit or abort is logged. Consequently, T2T_2 cannot obtain a shared read lock on XX and is blocked from reading uncommitted data. Thus, cascading rollbacks are eliminated.

    c. Write-Ahead Logging (WAL) and Recovery

    The Write-Ahead Logging (WAL) protocol mandates:

    1. The log record representing an update must be flushed to non-volatile disk before the modified data page is written to disk.
    2. All log records for a transaction must be flushed before the commit record is recorded.

    Deferred Update vs. Immediate Update:

    • Deferred Update (NO-UNDO/REDO): Updates are recorded only in the transaction log during execution; actual database buffers on disk are updated only after the transaction successfully commits. If system crashes before commit, no database rollback is needed (NO-UNDO). Committed transactions are redone (REDO).
    • Immediate Update (UNDO/REDO): Updates are applied to active database buffers and may be written to disk before the transaction commits. If a crash occurs before commit, uncommitted updates on disk must be rolled back (UNDO). Committed updates must be reapplied (REDO).

Group C

Comprehensive Answer / Case Analysis Question. (1 × 20 = 20)

[1*20=20]
  1. [20]

    MeroBank is a leading commercial bank in Nepal handling over 2 million digital transactions daily across mobile banking, interbank fund transfers (IPS), and core retail branches. During festival peak loads (Dashain/Tihar), the database engineering team observes significant performance degradation:\n1. Heavy transaction latency and intermittent lock timeouts during simultaneous fund transfers.\n2. Reporting queries run by branch managers block customer account balance updates.\n3. A sudden storage controller failure in the primary datacenter resulted in an extended recovery window of 4 hours, violating the bank’s Recovery Time Objective (RTO) of 15 minutes.\n\nAs Chief Database Architect, analyze this enterprise case and provide comprehensive technical solutions:\na. Explain how Transaction Isolation Levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) impact concurrency and consistency in banking. Recommend the appropriate isolation level for account balance transfers versus end-of-day audit reporting.\nb. Design a Concurrency Control mechanism using Multi-Version Concurrency Control (MVCC) to eliminate read-write contention.\nc. Propose an Indexing Strategy (B+ Trees vs. Hash Indexes) for customer account lookups and transaction history range queries.\nd. Formulate a Disaster Recovery and High-Availability Architecture using Write-Ahead Logging, Checkpointing (Fuzzy Checkpoints), and Active-Standby database replication to achieve RPO ≈ 0 and RTO < 15 minutes.

    View model answerHide model answer

    Comprehensive Enterprise Database Architecture Case Analysis: MeroBank

    a. Transaction Isolation Levels and Recommendations

    Isolation Level Dirty Read Non-Repeatable Read Phantom Read Concurrency Performance
    Read Uncommitted Possible Possible Possible Maximum
    Read Committed Prevented Possible Possible High
    Repeatable Read Prevented Prevented Possible Medium
    Serializable Prevented Prevented Prevented Lowest (High lock contention)

    Architectural Recommendations:

    1. Digital Fund Transfers (Debit/Credit): Must run under Repeatable Read or Serializable (or Snapshot Isolation with first-committer-wins conflict detection). When Account A transfers funds to Account B, both accounts must be debited and credited atomically without dirty reads or phantom balance updates.
    2. Branch Manager Audit & Analytics Reports: Must run under Read Committed (or Snapshot Isolation). Long-running read queries take a point-in-time snapshot, ensuring they never acquire shared read locks that block customer transactions.

    b. Multi-Version Concurrency Control (MVCC) Solution

    In traditional locking systems, readers block writers and writers block readers. MVCC resolves this contention by creating a new version of a data record whenever an update occurs:

    • How MVCC Works: Each row maintains two system timestamps: xmin (creation transaction ID) and xmax (deletion/expiration transaction ID).
    • Read Operations: When a transaction TT reads a record, the database engine returns the highest committed version of the row where xmin ≤Tstart\le T_{\text{start}} and xmax >Tstart> T_{\text{start}}.
    • Benefit for MeroBank: Long-running reporting queries read old, committed snapshots of account records while simultaneous customer fund transfers create new row versions without being blocked. Readers never block writers, and writers never block readers.

    c. Indexing Strategy: B+ Tree vs. Hash Indexing

    1. Customer Account Lookup (AccountNo exact match):
      • Hash Index: Provides O(1)O(1) time complexity for exact point queries (WHERE AccountNo = '01002345'). However, Hash indexes do not support range scans, sorting, or prefix matching.
      • B+ Tree Index: Provides O(log⁡N)O(\log N) lookup and supports range filtering.
      • Recommendation: Utilize a Unique B+ Tree Index on AccountNo as the clustered index. B+ trees maintain sorted leaf node linkage, which handles both point lookups and branch account sweeps efficiently.
    2. Transaction History Queries (WHERE TxnDate BETWEEN '2081-01-01' AND '2081-01-31'):
      • Recommendation: Implement a Composite Non-Clustered B+ Tree Index on (AccountNo, TxnDate DESC). The B+ tree leaf nodes contain contiguous doubly linked pointers, allowing fast index range scans for statement generation without full table scans.

    d. Disaster Recovery and High Availability (HA) Architecture

    To satisfy MeroBank’s RPO ≈0\approx 0 (zero data loss) and RTO <15< 15 minutes:

    1. Fuzzy Checkpointing:
      • Instead of flushing all dirty buffer pages to disk during a checkpoint (which halts disk I/O), the DBMS writes a CHECKPOINT_BEGIN record and records dirty page table (DPT) addresses. Dirty pages are written asynchronously in the background. The CHECKPOINT_END record allows the recovery engine to pinpoint the earliest log record required during recovery.
    2. ARIES Recovery Algorithm (Analysis, Redo, Undo):
      • Analysis Phase: Scans the log forward from the latest checkpoint to reconstruct the active transaction table and DPT.
      • Redo Phase: Scans forward from the earliest unwritten page LSN to redo all logged operations (both committed and uncommitted) to restore the exact pre-crash state.
      • Undo Phase: Scans backward to undo the changes of all active (uncommitted) transactions, writing compensating log records (CLRs).
    3. Active-Standby Database Replication:
      • Deploy Synchronous Physical Replication to a secondary standby database in a separate seismic zone (e.g., Pokhara or Butwal).
      • Core transactions commit only after write-ahead logs are synchronously acknowledged by the standby instance.
      • Automatic Failover: An automated cluster heartbeat manager triggers standby promotion within 60 to 90 seconds in the event of primary hardware failure, easily beating the 15-minute RTO target.