47.4 KB · commit 40bb182
| year | 2023 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2023 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 60 |
| time | 3 Hours |
| layer | exam-style |
← Prev: 2021 | Explanation Layer | Original Question Paper | Next: 2024 →
Topic: T02.5 · Design a full E-R diagram for a scenario · Section A · CLO4
Question.
Draw an ER diagram for RUET Central Library Management System. You have to consider the entities mentioned below:
(i) Books (ii) Members (iii) Staff (iv) Borrowing (v) Reservations
Answer.
Design Note: Borrowing and Reservations are explicitly specified as entity sets in the prompt; each is modeled with its own unique identifier and transaction attributes.
Entity Sets & Attributes:
book_id (PK), isbn, title, author, edition.member_id (PK), name, type, department.staff_id (PK), name, designation.borrow_id (PK), borrow_date, due_date, return_date.res_id (PK), res_date, status.Relationships:
Issues (1:N): A staff member processes multiple borrowings.Borrows (1:N): A member initiates multiple borrowings.Includes (N:1): A borrowing record links to the specific book borrowed.Reserves (1:N): A member makes multiple book reservations.For_Book (N:1): A reservation is placed for a specific book.
Figure: RUET Central Library Management System E-R Diagram
Topic: T01.2 · File system vs DBMS · Section A · CLO1 (Repeated question: Also asked in 2019 | Solved in T01)
Question. What are the advantages of DBMS over file processing system?
Answer.
Importance of DBMS:
A DBMS provides centralized, secure, and coordinated control over an organization's data. It replaces scattered operating system files and ensures that data remains reliable, shared, and recoverable during hardware or software crashes.
Advantages of DBMS over File Processing Systems:
Variant for 2023 Q.1(b) (3 marks): Focus directly on the 5 advantages over file processing systems; omit the general importance statement.
Topic: T01.5 · DDL vs DML · Section A · CLO1
Question. Explain DDL and DML with example.
Answer.
CREATE TABLE instructor (
ID CHAR(5),
name VARCHAR(20),
dept_name VARCHAR(20),
salary NUMERIC(8,2)
);
SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.';
Topic: T08.8 · Normalize an unnormalized table → 1NF → 2NF → 3NF · Section A · CLO4
Question.
Consider a university tracking students, their courses and exam scores. A sample table is given below. Step by step convert this to 3NF.
| S_ID | S-Name | Courses | Instructors | Grades |
|---|---|---|---|---|
| 1 | Alice | Math, Physics | Dr. Smith, Dr. Brown | A, B+ |
| 2 | Bob | Chemistry | Dr. White | A- |
| 3 | Charlie | Math, Biology, Chemistry | Dr. Smith, Dr. Gray, Dr. White | B+, A-, A |
Answer.
The sample table violates 1NF because the attributes Courses, Instructors, and Grades contain multi-valued entries.
To achieve 1NF, we flatten each multi-valued row into individual atomic records:
| S_ID | S-Name | Course | Instructor | Grade |
|---|---|---|---|---|
| 1 | Alice | Math | Dr. Smith | A |
| 1 | Alice | Physics | Dr. Brown | B+ |
| 2 | Bob | Chemistry | Dr. White | A- |
| 3 | Charlie | Math | Dr. Smith | B+ |
| 3 | Charlie | Biology | Dr. Gray | A- |
| 3 | Charlie | Chemistry | Dr. White | A |
Primary Key for 1NF: (S_ID, Course)
S_ID -> S-Name (partial dependency on S_ID)Course -> Instructor (partial dependency on Course)(S_ID, Course) -> Grade (full dependency on the composite key)In 1NF, S-Name and Instructor depend on parts of the composite primary key (S_ID, Course).
To eliminate these partial dependencies, we decompose the table into three relations:
STUDENT
| S_ID | S-Name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| 3 | Charlie |
PK: S_ID
COURSE
| Course | Instructor |
|---|---|
| Math | Dr. Smith |
| Physics | Dr. Brown |
| Chemistry | Dr. White |
| Biology | Dr. Gray |
PK: Course
ENROLLMENT
| S_ID | Course | Grade |
|---|---|---|
| 1 | Math | A |
| 1 | Physics | B+ |
| 2 | Chemistry | A- |
| 3 | Math | B+ |
| 3 | Biology | A- |
| 3 | Chemistry | A |
PK: (S_ID, Course)
All non-prime attributes in these three relations depend fully on their entire candidate keys. Thus, the schema is in 2NF.
A relation in 2NF is in 3NF if no non-prime attribute transitively depends on a candidate key.
STUDENT(S_ID, S-Name), S_ID is the candidate key and determines S-Name. No transitive dependency exists.COURSE(Course, Instructor), Course is the candidate key and determines Instructor. No transitive dependency exists.ENROLLMENT(S_ID, Course, Grade), (S_ID, Course) is the candidate key and determines Grade. No transitive dependency exists.Since there are no transitive dependencies, the 2NF schema is already in 3NF.
Final 3NF Schema: STUDENT(S_ID,S-Name),COURSE(Course,Instructor),ENROLLMENT(S_ID,Course,Grade)Topic: T08.1 · Why normalize: redundancy and insert/update/delete anomalies · Section A · CLO4
Question. What are the anomalies that normalization aims to eliminate? Provide examples of insertion, deletion and update anomalies.
Answer.
Normalization aims to eliminate three modification anomalies caused by data redundancy and undesirable functional dependencies:
EMP_DEPTConsider an unnormalized table where employee and department facts share one relation:
| Emp_ID | Emp_Name | Dept_ID | Dept_Name | Location |
|---|---|---|---|---|
| E01 | Alice | D10 | IT | Building A |
| E02 | Bob | D20 | HR | Building B |
| E03 | Charlie | D10 | IT | Building A |
Primary Key: Emp_ID
D30 (Finance, Building C). Because Emp_ID is the primary key, it cannot be NULL. We cannot record department D30 until an employee is hired.E02 is the only person working in department D20 (HR). If Bob resigns and we delete his row (E02), the fact that department D20 is HR located in Building B is permanently erased.D10) moves to "Building D", we must update both rows E01 and E03. If the system updates E01 but fails on E03, department D10 has two conflicting locations.Topic: T05.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · Section A · CLO2
Question.
Write SQL queries for the following:
(i) Create a table "Employee" with attributes: EmpID (primary key), Name, Age and Department.
(ii) Insert a record into this table: EmpID=1, Name='Nafisa', Age=21, department='HR'.
(iii) Find employees whose salary is greater than the average salary of their department.
Answer.
(i) Create table Employee:
CREATE TABLE Employee (
EmpID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT,
Department VARCHAR(30)
);
(ii) Insert record into Employee:
INSERT INTO Employee (EmpID, Name, Age, Department)
VALUES (1, 'Nafisa', 21, 'HR');
(iii) Find employees earning more than their department's average salary:
Assumption: The Employee relation includes an attribute Salary DECIMAL(10,2).
SELECT *
FROM Employee e1
WHERE e1.Salary > (
SELECT AVG(e2.Salary)
FROM Employee e2
WHERE e2.Department = e1.Department
);
Topic: T03.2 · Keys: super / candidate / primary / alternate / composite / foreign · Section A · CLO2
Question.
Explain the distinctions among the terms-
(i) Primary key
(ii) Candidate key
(iii) Super key
(iv) Composite key
Answer.
A key is an attribute or set of attributes used to identify rows in a table.
Distinctions Among Keys:
| Key Type | Definition | Minimality | NULL Allowed |
|---|---|---|---|
| (i) Primary Key | The candidate key chosen by the database designer to identify tuples uniquely. | Yes (minimal) | No (never allowed) |
| (ii) Candidate Key | A minimal super key. Removing any attribute destroys uniqueness. | Yes (strictly minimal) | Yes (unless constrained NOT NULL) |
| (iii) Super Key | Any set of attributes that uniquely identifies a row. May contain extra attributes. | No (can have redundant attributes) | No for identifying columns |
| (iv) Composite Key | A key that consists of two or more attributes rather than a single attribute. | Can be minimal (candidate) or non-minimal | Depends on whether it is PK or unique |
Relationship:
Primary Key⊆Candidate Keys⊆Super KeysRunning Example:
Consider relation Student(student_id,name,email,nid,dept_name):
| student_id | name | nid | dept_name | |
|---|---|---|---|---|
| 101 | Akib | akib@gmail.com | 1999123456 | ECE |
| 102 | Shuvo | shuvo@gmail.com | 2000654321 | ECE |
| 103 | Sakib | sakib@gmail.com | 2001987654 | ETE |
Short version for 2018 Q.2(a) (4 marks): Omit (iv) Composite key. Keep the definitions, distinctions table, and the Student running example for Super Key, Candidate Key, and Primary Key.
Short version for 2021 Q.2(b) (3 marks): Same as 2018 Q.2(a). Present the 3-row distinction table and the Student relation key classification.
Topic: T12.4 · RAID levels, comparison, and recovery role · Section A · CLO1
Question. Discuss the features of RAID models.
Answer.
A Redundant Array of Independent Disks (RAID) provides four major architectural features:
Topic: T09.1 · ACID properties · Section A · CLO3
Question. Briefly explain the importance of ACID properties of transactions with suitable example.
Answer.
Databases must handle two critical challenges: system failures (crashes, power loss) and concurrent user execution. The ACID properties are essential because without them, database data becomes corrupt and untrustworthy.
Example: Transaction T1 transfers $50 from account A ($1000) to account B ($2000). The invariant is A+B=3000.
Importance of Each Property:
Importance of Atomicity:
Importance of Consistency:
Importance of Isolation:
Importance of Durability:
Topic: T09.3 · Transaction states / life-cycle diagram · Section A · CLO3
Question. Draw state diagram of a transaction.
Answer.
Figure: Transaction State Diagram (Source: Deck 07, Slide 8)
State Transitions:
Topic: T06.4 · Views and CREATE VIEW · Section B · CLO2
Question. What are the benefits of VIEW?
Answer.
A view is a virtual relation defined by an SQL query. The database does not store the view data on disk. Instead, it stores the query definition and executes it when referenced.
Key Benefits of Views:
SELECT queries on the view.Topic: T06.4 · Views and CREATE VIEW · Section B · CLO2
Question.
Create a VIEW using SQL query that shows the EmployeeName, DepartmentName and salary for employees who earn a salary of more than 55,000.
E.
| EmployeeID | EmployeeName | Department ID |
|---|---|---|
| 101 | Jhon | D01 |
| 102 | Jane | D02 |
| 103 | Alice | D01 |
| 104 | Bob | D03 |
| DepartmentID | DepartmentName |
|---|---|
| D01 | Sales |
| D02 | HR |
| D03 | IT |
| EmployeeID | Salary |
|---|---|
| 101 | 50,000 |
| 102 | 60,000 |
| 103 | 55,000 |
| 104 | 70,000 |
Answer.
Assumption: Schema consists of Employee(EmpID, EmployeeName, Salary, DeptID) and Department(DeptID, DepartmentName).
SQL Query (Standard 2-Table Schema):
CREATE VIEW High_Salary_Employees AS
SELECT Employee.EmployeeName, Department.DepartmentName, Employee.Salary
FROM Employee
JOIN Department ON Employee.DeptID = Department.DeptID
WHERE Employee.Salary > 55000;
Alternative SQL Query (Using Printed Tables E, D, and S): Joining table E, table D, and table S:
CREATE VIEW High_Salary_Employees AS
SELECT E.EmployeeName, D.DepartmentName, S.Salary
FROM E
JOIN D ON E.`Department ID` = D.DepartmentID
JOIN S ON E.EmployeeID = S.EmployeeID
WHERE S.Salary > 55000;
View Output:
| EmployeeName | DepartmentName | Salary |
|---|---|---|
| Jane | HR | 60,000 |
| Bob | IT | 70,000 |
(Note: Employees Jhon with 50,000 and Alice with 55,000 are excluded because their salaries do not exceed 55,000).
Topic: T06.1 · Types of joins · Section B · CLO2 (Repeated question: Also asked in 2019 | Solved in T06)
Question. Define joining. Discuss different types of joining with suitable example.
Answer.
Definition of Joining:
A join operation takes two relations and combines them into one relation based on a matching condition. It acts as a Cartesian product followed by a selection predicate and projection.
Figure: Join types and join conditions (Deck 04, Slide 4)
Example Base Tables:
Table course:
| course_id | title | dept_name | credits |
|---|---|---|---|
| BIO-301 | Genetics | Biology | 4 |
| CS-190 | Game Design | Comp. Sci. | 4 |
| CS-315 | Robotics | Comp. Sci. | 3 |
Table prereq:
| course_id | prereq_id |
|---|---|
| BIO-301 | BIO-101 |
| CS-190 | CS-101 |
| CS-347 | CS-101 |
Retains only tuples that satisfy the join condition in both tables. Unmatched rows are dropped.
SELECT course.course_id, title, dept_name, prereq_id
FROM course
INNER JOIN prereq ON course.course_id = prereq.course_id;
Relational algebra:
course⋈prereqResult:
| course_id | title | dept_name | prereq_id |
|---|---|---|---|
| BIO-301 | Genetics | Biology | BIO-101 |
| CS-190 | Game Design | Comp. Sci. | CS-101 |
Preserves every row from the left table (course). Fills right-table attributes with NULL when no match exists.
SELECT course.course_id, title, dept_name, prereq_id
FROM course
LEFT JOIN prereq ON course.course_id = prereq.course_id;
Relational algebra:
course⟕prereqResult:
| course_id | title | dept_name | prereq_id |
|---|---|---|---|
| BIO-301 | Genetics | Biology | BIO-101 |
| CS-190 | Game Design | Comp. Sci. | CS-101 |
| CS-315 | Robotics | Comp. Sci. | NULL |
Preserves every row from the right table (prereq). Fills left-table attributes with NULL when no match exists.
SELECT prereq.course_id, title, dept_name, prereq_id
FROM course
RIGHT JOIN prereq ON course.course_id = prereq.course_id;
Relational algebra:
course⟖prereqResult:
| course_id | title | dept_name | prereq_id |
|---|---|---|---|
| BIO-301 | Genetics | Biology | BIO-101 |
| CS-190 | Game Design | Comp. Sci. | CS-101 |
| CS-347 | NULL | NULL | CS-101 |
Retains all rows from both tables. It pairs matching rows and fills missing values with NULL. MySQL emulates it using UNION.
SELECT course.course_id, title, dept_name, prereq_id
FROM course
LEFT JOIN prereq ON course.course_id = prereq.course_id
UNION
SELECT prereq.course_id, title, dept_name, prereq_id
FROM course
RIGHT JOIN prereq ON course.course_id = prereq.course_id;
Relational algebra:
course⟗prereqResult:
| course_id | title | dept_name | prereq_id |
|---|---|---|---|
| BIO-301 | Genetics | Biology | BIO-101 |
| CS-190 | Game Design | Comp. Sci. | CS-101 |
| CS-315 | Robotics | Comp. Sci. | NULL |
| CS-347 | NULL | NULL | CS-101 |
Combines each row of the first table with every row of the second table without any condition.
SELECT *
FROM course
CROSS JOIN prereq;
Relational algebra:
course×prereqIt returns 3×3=9 rows.
Variant for 2023 Q.5(c) (4 marks): The same definition and four outer and inner join examples answer the question.
Topic: T05.9 · TRUNCATE vs DELETE · Section B · CLO2
Question. What is the difference between 'Truncate' and 'Delete' in SQL?
Answer.
Both TRUNCATE and DELETE remove rows from a relation, but they operate at different architectural levels:
| Feature | TRUNCATE TABLE | DELETE FROM |
|---|---|---|
| Command Category | DDL (Data Definition Language) | DML (Data Manipulation Language) |
Row Filtering (WHERE) | Not supported; always empties the entire table | Supported; deletes specific filtered rows or all rows |
| Transaction & Rollback | Executes an implicit COMMIT in MySQL; cannot be rolled back | Logged row-by-row; can be rolled back inside a transaction |
| Triggers | Does not fire DELETE triggers | Fires BEFORE DELETE and AFTER DELETE triggers for each row |
AUTO_INCREMENT Counter | Resets the auto-increment counter back to its starting value (1) | Preserves the current auto-increment counter sequence |
| Execution Speed | Extremely fast; deallocates data pages directly | Slower; scans rows and records individual undo/redo logs |
Topic: T07.3 · Implement a trigger or stored procedure · Section B · CLO2
Question.
Considering the tables (Products, Orders, and Auditlog) answer (i) and (ii).
(i) Create a stored procedure to place an order consider stock availability, updates the stock.
(ii) Create a trigger to log every stock update in the Auditlog table automatically.
Answer.
Assumption: The table schemas are Products(product_id, name, stock, price), Orders(order_id, product_id, quantity, order_date), and Auditlog(log_id, product_id, old_stock, new_stock, changed_at).
The stored procedure verifies available stock using row-level locking (FOR UPDATE), places the order, and reduces the inventory within a transaction:
DELIMITER //
CREATE PROCEDURE PlaceOrder (
IN p_product_id INT,
IN p_quantity INT
)
BEGIN
DECLARE v_stock INT;
START TRANSACTION;
-- Lock the target product row to prevent concurrent race conditions
SELECT stock INTO v_stock
FROM Products
WHERE product_id = p_product_id
FOR UPDATE;
-- Validate product existence and stock sufficiency
IF v_stock IS NULL THEN
ROLLBACK;
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Product does not exist';
ELSEIF v_stock < p_quantity THEN
ROLLBACK;
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Insufficient stock available';
ELSE
-- Record the new order
INSERT INTO Orders (product_id, quantity, order_date)
VALUES (p_product_id, p_quantity, NOW());
-- Deduct ordered quantity from stock
UPDATE Products
SET stock = stock - p_quantity
WHERE product_id = p_product_id;
COMMIT;
END IF;
END //
DELIMITER ;
An AFTER UPDATE trigger detects when the stock column changes and writes an audit record to Auditlog:
DELIMITER //
CREATE TRIGGER trg_log_stock_update
AFTER UPDATE ON Products
FOR EACH ROW
BEGIN
-- Log only when the stock quantity actually changes
IF OLD.stock <> NEW.stock THEN
INSERT INTO Auditlog (product_id, old_stock, new_stock, changed_at)
VALUES (OLD.product_id, OLD.stock, NEW.stock, NOW());
END IF;
END //
DELIMITER ;
Topic: T05.8 · Short notes: ON DELETE CASCADE, GROUP BY, ORDER BY, AS · Section B · CLO2 (Repeated question: Also asked in 2024 | Solved in T05)
Question. Write short note on " ON CASCADE DELETE".
Answer.
i) ON DELETE CASCADE (printed as "ON CASCADE DELETE"):
A foreign key referential integrity action. When a tuple in the parent table is deleted, the DBMS automatically deletes all corresponding referencing tuples in the child table. This maintains referential integrity and prevents orphaned records.
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY (course_id) REFERENCES course(course_id)
ON DELETE CASCADE
);
ii) GROUP BY:
An SQL clause used to partition table rows into distinct groups having identical values in specified columns. Aggregate functions (COUNT, SUM, AVG, MIN, MAX) then compute summary statistics for each individual group.
SELECT dept_name, AVG(salary) AS avg_sal
FROM instructor
GROUP BY dept_name;
iii) ORDER BY:
An SQL clause that sorts query result rows in ascending (ASC, default) or descending (DESC) order based on one or more attributes. Multiple sort keys break ties sequentially.
SELECT name, salary
FROM instructor
ORDER BY salary DESC, name ASC;
iv) AS:
An SQL keyword used to define an alias (an alternative temporary name). It can rename an attribute or computed expression in the SELECT clause for readability, or rename a table in the FROM clause to shorten table references and enable self-joins.
SELECT salary * 1.15 AS revised_salary
FROM employee AS e;
Short version for 2019 Q.8(c) (4 marks): Provide parts (i) and (ii).
Short version for 2023 Q.6(c) (2 marks): Provide part (i) with definition, syntax, and effect.
Topic: T12.1 · Failure classification, precautions, recovery methods · Section B · CLO2 (Repeated question: Also asked in 2017 | Solved in T12)
Question. Explain the different types of failures that can occur in a database system.
Answer.
A database management system experiences three main classes of failure based on the affected storage component:
Variant for 2023 Q.7(a) (CLO2, 3 marks): The same three-part classification directly answers the question.
Topic: T12.3 · Log-based recovery and shadow paging · Section B · CLO2
Question. What is log based recovery? Illustrate with an example of a system crash and recovery process.
Answer.
Log-based recovery is a crash recovery technique that records all database update actions on stable storage in a sequential log prior to updating the database on disk. By maintaining both old and new values, the recovery manager can undo incomplete transactions and redo committed transactions after a failure.
Consider three transactions running on data items A, B, and C with initial values A=1000, B=2000, and C=500:
State of Log on Stable Storage at Crash:
1. <T1 start>
2. <T1, A, 1000, 900>
3. <T1, B, 2000, 2100>
4. <T1 commit>
5. <T2 start>
6. <T2, C, 500, 700>
7. <T3 start>
8. <T2 commit>
9. <T3, B, 2100, 2050>
---- CRASH OCCURS HERE ----
<start> and <commit> records).<start> but no <commit> or <abort> record).Final Database State: A=900, B=2100, C=700. Both atomicity for T3 and durability for T1 and T2 are satisfied.
Topic: T12.4 · RAID levels, comparison, and recovery role · Section B · CLO2
Question. Briefly describe the RAID model and its significance in database recovery.
Answer.
The RAID (Redundant Array of Independent Disks) model combines multiple physical disk drives into a single logical unit. It uses data striping for parallel speed and data redundancy (mirroring or parity) for reliability.
Topic: T13.3 · Indexing: dense vs sparse index · Section B · CLO1
Question. Write short note on dense and sparse index.
Answer.
1. Definitions
Figure 13.1: Dense index on instructor file with search key ID (Source: Textbook Ch. 14, Fig. 14.2).
Figure 13.2: Sparse index on instructor file with search key ID (Source: Textbook Ch. 14, Fig. 14.3).
2. Comparison
| Feature | Dense Index | Sparse Index |
|---|---|---|
| Index Entries | One entry for every search-key value in the file. | One entry for only some search-key values (usually one per disk block). |
| Lookup Speed | Faster. Locates the exact record or its list of duplicates directly. | Slower. Requires an index lookup followed by a sequential block scan. |
| Space Overhead | Large. The index file consumes significant disk or memory space. | Small. The index file is much smaller and often fits in main memory. |
| File Ordering | Can be built on sorted (clustering) or unsorted (non-clustering) files. | Requires the data file to be ordered on the search key (clustering only). |
| Maintenance Cost | High. Insertions and deletions often require adding or removing index entries. | Low. Records can often be inserted or deleted inside a block without updating the index. |
Practical Trade-off: A sparse index with one entry per disk block offers a good compromise between lookup speed and index size.
Topic: T10.3 · Precedence-graph test → cycle → serial order(s) · Section B · CLO3
Question.
Check whether the given schedules S is conflict serializeable or not. If yes, then determine all the possible serialized schedules.
| T1 | T2 | T3 | T4 |
|---|---|---|---|
| R(A) | |||
| R(A) | |||
| W(B) | |||
| R(A) | |||
| W(A) | |||
| R(B) | |||
| W(B) |
Answer.
We list the operations of schedule S in chronological order:

The edges of the graph are:
T1⟶T3,T3⟶T2,T4⟶T2,T1⟶T2The precedence graph is acyclic (it is a Directed Acyclic Graph). Therefore, schedule S is conflict serializable.
From the graph dependencies:
We interleave T4 anywhere before T2. This yields exactly 3 valid topological sorts:
Topic: T11.6 · Timestamp ordering: R-TS/W-TS rules, trace a schedule; rolled-back transaction gets a NEW timestamp · Section B · CLO3
Question.
Discuss the given schedule based on Timestamp ordering protocol.
| T1(100) | T2(200) | T3(300) |
|---|---|---|
| R(A) | ||
| R(B) | ||
| W(C) | ||
| R(B) | ||
| R(C) | ||
| W(B) | ||
| W(A) |
Answer.
Initial Setup:
Step-by-Step Execution Trace:
| Step | Txn | Op | Protocol Condition Check | Decision | Updated Timestamp State |
|---|---|---|---|---|---|
| 1 | T1 | R(A) | TS(T1)≥W-TS(A)⟹100≥0 (Valid) | Execute | R-TS(A)=max(0,100)=100 |
| 2 | T2 | R(B) | TS(T2)≥W-TS(B)⟹200≥0 (Valid) | Execute | R-TS(B)=max(0,200)=200 |
| 3 | T1 | W(C) | TS(T1)≥R-TS(C) and W-TS(C)⟹100≥0 (Valid) | Execute | W-TS(C)=100 |
| 4 | T3 | R(B) | TS(T3)≥W-TS(B)⟹300≥0 (Valid) | Execute | R-TS(B)=max(200,300)=300 |
| 5 | T1 | R(C) | TS(T1)≥W-TS(C)⟹100≥100 (Valid) | Execute | R-TS(C)=max(0,100)=100 |
| 6 | T2 | W(B) | TS(T2)<R-TS(B)⟹200<300 (Violated!) | REJECTED | T2 is rolled back |
| 7 | T3 | W(A) | TS(T3)≥R-TS(A) and W-TS(A)⟹300≥100 (Valid) | Execute | W-TS(A)=300 |
Evaluation and Discussion:
Conclusion:
The schedule is not accepted without rollback. Transaction T2 is aborted and rolled back at Step 6. When restarted, T2 must be assigned a new timestamp greater than 300.
← Prev: 2021 | Explanation Layer | Original Question Paper | Next: 2024 →