Tribhuvan University
Faculty of Management
Office of the Dean
2021 AD / Regular Examination
Time: 2 hrs. | Full Marks: 40 | Pass Marks: 20
Subjective Questions
- [2]
How the Redundancy problem in File Processing is solved by database processing ?
View model solution
How Database Processing Solves Data Redundancy
In traditional file processing systems, each department or application maintains its own private, isolated files. This causes identical pieces of data (e.g., student address) to be duplicated across multiple independent files, leading to storage waste and data inconsistency.
DBMS Solution:
- Centralized Data Repository: All data is integrated into a unified database schema controlled by the DBMS. Multiple application modules access the exact same shared physical tables.
- Controlled/Minimal Redundancy: Where duplication is required for performance (such as foreign keys), the DBMS maintains consistency automatically through foreign key referential integrity constraints.
- Single Source of Truth: An update made in one table (e.g., updating customer address) is immediately reflected across all reporting views, eliminating contradictory records.
- [2]
List out the responsibility of DBA.
View model solution
Responsibilities of a Database Administrator (DBA)
A Database Administrator (DBA) is the person or group responsible for the centralized operational control, configuration, maintenance, and security of the entire database system.
Key Responsibilities:
- Schema Definition & Modification: Designing and creating conceptual, physical, and external database schemas using DDL statements.
- Storage Structure & Access Method Definition: Configuring physical file allocations, tablespaces, indexing strategies, and clustering parameters.
- Granting User Authorization & Security: Assigning roles, usernames, passwords, and fine-grained permissions (
GRANT/REVOKE) to prevent unauthorized data access. - Integrity Constraint Specification: Enforcing domain constraints, primary keys, foreign keys, and business validation rules.
- Backup and Disaster Recovery: Formulating routine automated backup schedules and executing restoration procedures following system failures.
- [2]
What is the purpose of storage manager?
View model solution
Purpose of Storage Manager in a DBMS
The Storage Manager is a critical system module in the DBMS engine that provides the operational interface between the low-level data stored on physical disks (raw disk blocks) and the high-level application queries and transactions submitted to the system.
Key Functions:
- Buffer Management: Allocates and manages main memory RAM cache (buffer pool) to minimize expensive physical disk I/O operations.
- File & Record Organization: Manages physical space allocation on block devices and maintains internal record layouts and free-space maps.
- Indexing: Manages B+ tree and hash index structures for rapid record retrieval.
- Transaction Logging: Interfaces with the transaction manager to write Write-Ahead Log (WAL) records for crash recovery.
- [2]
Give example of Binary and Ternary relationship.
View model solution
Binary and Ternary Relationships with Examples
The degree of a relationship refers to the number of participating entity sets:
1. Binary Relationship (Degree = 2):
Associates instances from two entity sets.
- Example:
EmployeeWorks_InDepartment.- Entities:
Employee,Department - Relationship:
Works_In
- Entities:
2. Ternary Relationship (Degree = 3):
Simultaneously associates instances from three distinct entity sets.
- Example:
VendorSuppliesPartto aProject.- Entities:
Vendor,Part,Project - Relationship:
Supplies(signifies that a specific vendor supplies a particular part specifically for a given project).
- Entities:
- Example:
- [2]
Explain the two types of participation constraint.
View model solution
Two Types of Participation Constraints in ER Modeling
Participation constraint specifies whether the existence of an entity depends on its being related to another entity via the relationship set:
1. Total (Mandatory) Participation:
- Definition: Every single entity instance in the entity set must participate in at least one relationship instance in the relationship set.
- ER Notation: Represented by a double line connecting the entity set rectangle to the relationship diamond.
- Example: Every
Loanentity must be associated with at least oneCustomer.
2. Partial (Optional) Participation:
- Definition: Some entity instances in the entity set may not participate in any relationship instance.
- ER Notation: Represented by a standard single line.
- Example: Not every
Customermust have taken aLoan(some may only maintain deposit accounts).
- [2]
What is meant by lossless-join decomposition?
View model solution
Concept of Lossless-Join Decomposition
A decomposition of a relational schema (R) into two sub-schemas (R_1) and (R_2) is termed lossless-join (or non-additive join) if joining the two projected relations with natural join ((\bowtie)) guarantees exact reconstruction of the original relation (R) without generating any spurious (false) tuples:
Formal Mathematical Condition:
The decomposition is lossless with respect to a set of functional dependencies (F) if and only if the common attribute(s) forms a superkey for at least one of the decomposed relations:
- [2]
Define deletion Anomaly.
View model solution
Definition of Deletion Anomaly
A Deletion Anomaly is an unintended, undesirable consequence of unnormalized relational database design where the deletion of one specific piece of factual data causes the involuntary, permanent loss of other completely unrelated valid data.
Example:
Consider an unnormalized table:
- If a student is the only enrollee in a specialized course (e.g., “Advanced AI”), deleting that student’s enrollment record from the table also inadvertently deletes the course’s existence, title, and faculty details from the university system.
- [2]
what is embedded SQL?
View model solution
Concept of Embedded SQL
Embedded SQL refers to the inclusion of hard-coded SQL Data Manipulation (DML) and Data Definition (DDL) statements directly inside the source code of a general-purpose host programming language (such as C, C++, COBOL, or Java).
Key Characteristics:
- Preprocessor Directives: In C/C++, embedded SQL statements are prefixed by
EXEC SQLand terminated by a semicolon;. - Host Variables: Uses host programming language variables (prefixed with a colon
:) to pass data parameters into SQL queries and receive result column values. - Cursor Mechanism: Uses cursors to iterate row-by-row over multi-row SQL result sets, bridging the impedance mismatch between set-oriented SQL and procedural record-at-a-time host languages.
- Preprocessor Directives: In C/C++, embedded SQL statements are prefixed by
- [2]
What are two pitfalls (problem) of lock-based protocol ?
View model solution
Two Pitfalls (Problems) of Lock-Based Protocols
While lock-based concurrency control protocols ensure serializability, they suffer from two major operational problems:
-
Deadlock:
- Occurs when two or more transactions are in a circular wait state, each holding a lock on a data item that another transaction requires to proceed (e.g., (T_1) holds lock on (A) waiting for (B); (T_2) holds lock on (B) waiting for (A)).
- Neither transaction can proceed, requiring the DBMS to detect the cycle and abort/rollback one transaction.
-
Starvation (Livelock):
- Occurs when a transaction repeatedly waits indefinitely for a lock on a data item because a continuous succession of other higher-priority transactions are granted conflicting locks before it.
-
- [2]
Define Atomicity with example.
View model solution
Definition of Atomicity with Example
Atomicity is the “all-or-nothing” property of database transactions (the ‘A’ in ACID). It guarantees that either all operations belonging to the transaction execute to successful completion and commit, or if any failure occurs, the entire transaction is completely aborted and rolled back, leaving the database unchanged.
Practical Banking Example:
Suppose Rs. 5,000 is transferred from Account A to Account B:
Read(A)A = A - 5000Write(A)- --- System Crash / Power Failure occurs here ---
Read(B)B = B + 5000Write(B)
- Under Atomicity: The transaction manager detects the crash at Step 4 and undoes Steps 1–3, restoring Account A to its original balance. Money is never deducted from A without being credited to B.
- [5]
Draw ER diagram on the basis of following scenario assuming your own attributes. This system store various information about driver, bus tickets and customer. Driver drives bus, customer travel from one place to another by bus. Driver check the ticket of each customer for validity. Each customer must have ticket to travel by the bus.
View model solution
Entity-Relationship (ER) Diagram for Bus Ticketing System
1. Identified Entities and Attributes:
Driver:DriverID(PK),Name,LicenseNo,ContactNo.Bus:BusNo(PK),PlateNo,Capacity,Model.Customer:CustomerID(PK),Name,Phone,Email.Ticket:TicketNo(PK),SeatNo,Source,Destination,Fare,TravelDate,Status.
2. Relationships & Structural Constraints:
- Drives: Between
DriverandBus(1:1 or 1:N cardinality; a driver drives a designated bus). - Books / Has: Between
CustomerandTicket(1:N; a customer must have at least one ticket to travel; Total participation). - Validates / Checks: Between
DriverandTicket(1:N; driver verifies validity of customer tickets). - Assigned_To: Between
TicketandBus(N:1; ticket is issued for a specific bus).
3. ER Diagram Representation:
+------------+ +------------+ +------------+ | Driver |---(Drives)--| Bus |<---(For)---| Ticket | +------------+ +------------+ +------------+ | ^ | | +-------------------(Validates)-----------------------+ ^ | (Has) | +------------+ | Customer | +------------+ - [5]
Write the DDL statement to create the following table: Table Name: Football Team
Field Name Data - Type Constraints Team ID Alphanumeric Primary Key Team Name Character Not more than 20 character Rank Integer No negative and NULL Goal Score Integer No negative and NULL GoalConsided Integer NO NEGATIVE NULL No_of_players Integer Not less than 11 and more than 25 View model solution
SQL DDL Statement to Create the “Football Team” Table
CREATE TABLE Football_Team ( Team_ID VARCHAR(10) NOT NULL, Team_Name VARCHAR(20) NOT NULL, Rank INT NOT NULL, Goal_Score INT NOT NULL, GoalConsided INT NOT NULL, No_of_players INT NOT NULL, -- Table Constraints CONSTRAINT PK_FootballTeam PRIMARY KEY (Team_ID), CONSTRAINT CHK_TeamRank CHECK (Rank >= 0), CONSTRAINT CHK_GoalScore CHECK (Goal_Score >= 0), CONSTRAINT CHK_GoalConsided CHECK (GoalConsided >= 0), CONSTRAINT CHK_PlayerCount CHECK (No_of_players >= 11 AND No_of_players <= 25) );Explanation of Schema Constraints:
VARCHAR(10)alphanumeric data type chosen forTeam_IDwithPRIMARY KEYenforcing uniqueness andNOT NULL.Team_Name VARCHAR(20)enforces character limit not exceeding 20.Rank,Goal_Score, andGoalConsidedenforceNOT NULLand non-negative values (>= 0).No_of_playersenforces the required range from 11 to 25 inclusive viaCHECKconstraint.
- [5]
Consider the following relation database. Author (AID, A_Name, Age, Address, country) Publishes (AID, BID, publisheddate) Book (BID, B_name, page, price) a. Find the Name of Author who is Not from ‘Nepal’. b. Find the number of books written by each author. c. Find the name of Author who has published expensive book. d. Insert the detail of new Author.
View model solution
SQL Queries for Author, Publishes, and Book Schema
Schema:
Author (AID, A_Name, Age, Address, country)Publishes (AID, BID, publisheddate)Book (BID, B_name, page, price)
a) Find the Name of Author who is NOT from ‘Nepal’:
SELECT A_Name FROM Author WHERE country <> 'Nepal';
b) Find the number of books written by each author:
SELECT A.AID, A.A_Name, COUNT(P.BID) AS Total_Books_Written FROM Author A LEFT JOIN Publishes P ON A.AID = P.AID GROUP BY A.AID, A.A_Name;
c) Find the name of Author who has published the most expensive book:
SELECT DISTINCT A.A_Name FROM Author A JOIN Publishes P ON A.AID = P.AID JOIN Book B ON P.BID = B.BID WHERE B.price = (SELECT MAX(price) FROM Book);
d) Insert the detail of a new Author:
INSERT INTO Author (AID, A_Name, Age, Address, country) VALUES (101, 'Parijat', 56, 'Kathmandu', 'Nepal'); - [5]
Consider the relation scheme R={E,F,G,H,I,J,K,L,M,N} and the set of functional dependencies {{E,F}→{G},{F}→{I,J},{E,H}→{K,L},K→{M},L→{N}} ON R. what is the candidate key for R?
View model solution
Finding Candidate Key for Relation Schema
Given Schema:
Functional Dependencies (
): {E, F} -> {G}{F} -> {I, J}{E, H} -> {K, L}{K} -> {M}{L} -> {N}
Step 1: Identify Attributes Not Appearing on Any Right-Hand Side (RHS)
- Attributes appearing on the RHS:
G, I, J, K, L, M, N - Attributes never appearing on the RHS:
E, F, H
Conclusion: Since
E,F, andHare never determined by any other attribute, they must be part of every candidate key.Step 2: Compute Attribute Closure of
{E, F, H}^+ = {E, F, H}- By FD 1 (
{E, F} -> {G}):{E, F, H, G} - By FD 2 (
{F} -> {I, J}):{E, F, H, G, I, J} - By FD 3 (
{E, H} -> {K, L}):{E, F, H, G, I, J, K, L} - By FD 4 (
{K} -> {M}):{E, F, H, G, I, J, K, L, M} - By FD 5 (
{L} -> {N}):{E, F, H, G, I, J, K, L, M, N} = R
Since
{E, F, H}^+determines all attributes in (R) and no proper subset of{E, F, H}can determine (R): - [5]
Normalize the following relation up to BCNF.
E-ID E-name Contact No Post Salary E01 Sushil 98405,21325 Manager 40000 E02 Basanta 9846 Engineer 45000 E03 Gopal 98510,2456 Manager 40000 E04 Rita 98302 Accountant 30000 E05 Sita 986045,44534 Engineer 45000 View model solution
Normalizing Employee Relation Up to BCNF
Given unnormalized Employee table:
- Columns:
E-ID,E-name,Contact No,Post,Salary - Data has multi-valued contact numbers (e.g.,
98405, 21325).
Step 1: Normalization to First Normal Form (1NF)
- Violation in raw table:
Contact Nocontains multi-valued non-atomic values. - 1NF Rule: Every column must contain only atomic (indivisible) values.
- Resolution: Flatten rows so each cell holds exactly one phone number:
E-ID E-name Contact_No Post Salary E01 Sushil 98405 Manager 40000 E01 Sushil 21325 Manager 40000 E02 Basanta 9846 Engineer 45000 E03 Gopal 98510 Manager 40000 E03 Gopal 2456 Manager 40000 E04 Rita 98302 Accountant 30000 E05 Sita 986045 Engineer 45000 E05 Sita 44534 Engineer 45000 Composite Primary Key for 1NF:
{E-ID, Contact_No}.Step 2: Normalization to 2NF & 3NF
- Functional Dependencies:
E-ID -> E-name, Post, Salary(Partial dependency on composite key{E-ID, Contact_No}).Post -> Salary(Transitive dependency).
Decompose into 3NF:
Employee (E-ID, E-name, Post)with PK:E-ID.Employee_Phone (E-ID, Contact_No)with composite PK:{E-ID, Contact_No}and FK:E-ID.Job_Post (Post, Salary)with PK:Post.
Step 3: Normalization to BCNF (Boyce-Codd Normal Form)
- BCNF Requirement: For every functional dependency (X \rightarrow Y), (X) must be a superkey.
- In all three relations:
Employee: DeterminantE-IDis candidate key (\rightarrow) in BCNF.Employee_Phone: Key is{E-ID, Contact_No}, no non-trivial FDs (\rightarrow) in BCNF.Job_Post: DeterminantPostis candidate key (\rightarrow) in BCNF.
- Columns:
- [10]
Explain concurrency control. suppose you have three account A=5500, B=4500 and C=2000 and transaction T1, T2 and T3. in T1 Rs.500 transfer from A to B. in of all account. manage the transaction using Two phase locking protocol for concurrency control.
View model solution
Concurrency Control & Two-Phase Locking (2PL) Protocol
1. Why Concurrency Control is Needed:
When multiple database transactions execute concurrently, uncoordinated interleaved operations on shared data items lead to anomalies:
- Lost Updates
- Dirty Reads (Temporary Update)
- Unrepeatable / Inconsistent Reads
2. Two-Phase Locking (2PL) Protocol:
2PL guarantees conflict serializability by requiring each transaction to acquire and release locks in two distinct phases:
- Growing Phase: A transaction may acquire locks of any type (Shared
Sor ExclusiveX), but may not release any lock. - Lock Point: The moment when the transaction has acquired the final lock it requires.
- Shrinking Phase: A transaction may release locks, but may not acquire any new lock.
3. Scenario Management:
Given accounts: (A = 5500, B = 4500, C = 2000).
- (T_1): Transfer Rs. 500 from A to B:
Lock-X(A)(Growing)Read(A)(\rightarrow A = 5500 - 500 = 5000),Write(A)Lock-X(B)(Growing)Read(B)(\rightarrow B = 4500 + 500 = 5000),Write(B)Unlock(A)(Shrinking begins)Unlock(B)
- By strictly growing locks before releasing any lock, serializability is maintained, ensuring consistency across accounts.
- [10]
Explain various database Application Architecture with a suitable example.
View model solution
Database Application Architectures
Database application architecture defines how the database engine, application logic, and user interface components are partitioned and distributed across computing hardware:
1. Teleprocessing (1-Tier / Centralized) Architecture:
- All processing—user interface display, business logic execution, and DBMS operations—runs on a single central mainframe computer.
- Users interact via simple dumb display terminals.
2. Two-Tier Client-Server Architecture:
- Client Tier: Runs the User Interface and application logic (Fat Client). Communicates with the server via database connectivity APIs (JDBC, ODBC).
- Server Tier: Runs the DBMS software responsible for query evaluation, transaction control, and disk storage.
- Advantage: Offloads UI processing to client workstations.
- Disadvantage: High network traffic and maintenance cost when updating client software on hundreds of machines.
3. Three-Tier Web Architecture:
- Presentation Tier (Client): Thin client running in a web browser (HTML5, CSS, Vue/Nuxt, JavaScript).
- Application Tier (Business Logic Server): Web/Application servers (Node.js, Spring Boot, Python) running business validation and workflows.
- Database Tier (Backend Server): Dedicated enterprise database server (PostgreSQL, Oracle, MySQL).
- Advantages: Highly scalable, secure (clients never connect directly to database), clean separation of concerns.