Tribhuvan University
Faculty of Management
Office of the Dean
Official Model Question Paper / Dean's Office Blueprint
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]- [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]
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.
- [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
is in Boyce-Codd Normal Form (BCNF) if and only if for every non-trivial functional dependency holding over : must be a superkey of relation . In other words, BCNF strictly eliminates all functional dependencies where the determinant (
) is not a candidate key, thereby removing anomalies that can survive 3NF when overlapping candidate keys exist. - [2]
State the ACID properties in database transaction processing.
View model answerHide model answer
ACID Properties of Database Transactions
- Atomicity (All-or-Nothing): Guarantees that all operations within a transaction execute completely or none of them are reflected in the database.
- Consistency (Preservation of Invariants): Ensures the transaction transitions the database from one valid state satisfying all integrity constraints to another valid state.
- Isolation (Concurrent Independence): Guarantees that the intermediate states of concurrently executing transactions are invisible to one another.
- Durability (Persistence): Ensures that once a transaction commits, its state updates persist permanently in non-volatile storage, surviving subsequent system crashes.
- [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 WHEREclause 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 DELETEDML triggers.Does not invoke DML delete triggers.
Group B
Descriptive Answer Questions. Attempt any THREE questions. (3 × 10 = 30)
[3*10=30]- [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: {
, DeptName, OfficeLocation} - PROFESSOR: {
, Name, Qualification} - COURSE: {
, CourseTitle, Credits} - STUDENT: {
, FullName, Semester}
- DEPARTMENT: {
- Relationships & Cardinalities:
- Chairs (PROFESSOR to DEPARTMENT):
(One professor chairs one department). - Works_In (PROFESSOR to DEPARTMENT):
(Many professors belong to one department). - Offers (DEPARTMENT to COURSE):
(One department offers many courses). - Enrolls (STUDENT to COURSE):
(Many students enroll in many courses; Relationship attribute: Grade,AcademicYear).
- Chairs (PROFESSOR to DEPARTMENT):
b. Relational Schema Mapping
- DEPARTMENT (
, DeptName, OfficeLocation, ChairProfID*) - Foreign Key:
ChairProfIDreferencesPROFESSOR(EmployeeID)(Unique).
- Foreign Key:
- PROFESSOR (
, Name, Qualification, DeptID*) - Foreign Key:
DeptIDreferencesDEPARTMENT(DeptID).
- Foreign Key:
- COURSE (
, CourseTitle, Credits, DeptID*) - Foreign Key:
DeptIDreferencesDEPARTMENT(DeptID).
- Foreign Key:
- STUDENT (
, FullName, Semester) - ENROLLMENT (
, AcademicYear, Grade) - Composite Primary Key:
(RollNo, CourseCode) - Foreign Keys:
RollNoreferencesSTUDENT(RollNo),CourseCodereferencesCOURSE(CourseCode).
- Composite Primary Key:
- Entities & Attributes:
- [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:
- 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:
- 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' );
- Relational Algebra:
- [10]
Consider a relation schema
with the following set of functional dependencies:\n \n\nRequired:\na. Find all candidate keys of relation .\nb. Determine the highest normal form of relation .\nc. Decompose 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
: - Closure of
: - Thus,
is a candidate key.
- From
: Closure of . Thus is a candidate key. - From
: Closure of . Thus is a candidate key. - From
: Closure of . Thus is a candidate key. - From
: Closure of . Thus is a candidate key.
Prime Attributes:
(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
are prime attributes, there are no non-prime attributes. Therefore, is in 2NF. - 3NF: For every
, either is a superkey OR is a prime attribute. - In
: is not a superkey, but is a prime attribute (holds!). - In
: is not a superkey, but is prime (holds!). - In
: is not a superkey, but is prime (holds!). - In
: is not a superkey, but is prime (holds!). - Therefore,
is in 3NF.
- In
- BCNF: Requires
to be a superkey for every non-trivial . In , is not a superkey (closure of is ). Hence, is NOT in BCNF. - Highest Normal Form: 3NF.
c. Decomposing into BCNF
To eliminate violations of BCNF:
- Identify violating dependency:
( ). - Decompose
into with candidate key . - Remaining relation:
.
- Decompose
- In
, candidate keys are . - Dependencies holding in
: . violates BCNF ( is not a superkey of ). - Decompose
into and .
- Dependencies holding in
- In
, violates BCNF. - Decompose into
and .
- Decompose into
- In
, (via ). - Decompose into
and .
- Decompose into
Final BCNF Relations:
, , , , . This decomposition is strictly lossless.
- Closure of
- [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:
- Growing Phase: The transaction may obtain new locks (shared or exclusive) but cannot release any lock.
- 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
writes an uncommitted value to item , transaction reads that dirty value of , and subsequent failure of forces to abort as well. In Strict 2PL, transaction never releases its exclusive lock on until its commit or abort is logged. Consequently, cannot obtain a shared read lock on 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:
- The log record representing an update must be flushed to non-volatile disk before the modified data page is written to disk.
- 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]- [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:
- 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.
- 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) andxmax(deletion/expiration transaction ID). - Read Operations: When a transaction
reads a record, the database engine returns the highest committed version of the row where xminand xmax. - 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
- Customer Account Lookup (
AccountNoexact match):- Hash Index: Provides
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
lookup and supports range filtering. - Recommendation: Utilize a Unique B+ Tree Index on
AccountNoas the clustered index. B+ trees maintain sorted leaf node linkage, which handles both point lookups and branch account sweeps efficiently.
- Hash Index: Provides
- 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.
- Recommendation: Implement a Composite Non-Clustered B+ Tree Index on
d. Disaster Recovery and High Availability (HA) Architecture
To satisfy MeroBank’s RPO
(zero data loss) and RTO minutes: - Fuzzy Checkpointing:
- Instead of flushing all dirty buffer pages to disk during a checkpoint (which halts disk I/O), the DBMS writes a
CHECKPOINT_BEGINrecord and records dirty page table (DPT) addresses. Dirty pages are written asynchronously in the background. TheCHECKPOINT_ENDrecord allows the recovery engine to pinpoint the earliest log record required during recovery.
- Instead of flushing all dirty buffer pages to disk during a checkpoint (which halts disk I/O), the DBMS writes a
- 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).
- 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.