86.4 KB · commit 40bb182
| year | 2017 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2017 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 72 |
| time | 3 Hours |
| layer | explanation |
← Directory Overview | Exam-Style Layer | Original Question Paper | Next: 2018 →
Topic: T01.2 · File system vs DBMS · Section A
Question. Write down four significant differences between a file processing system and a DBMS.
Answer.
What the examiner wants.
Four distinct architectural differences between an operating system file processing system and a DBMS. The mark split is 1 mark per difference. Examiners expect key technical concepts: redundancy, ad-hoc access, data independence, and concurrency or crash recovery.
Key idea.
An operating system file stores a sequence of bytes. The OS does not understand the internal structure of the data inside the file. In contrast, a DBMS understands data structures, enforces relations and constraints, coordinates concurrent users, and guarantees recovery after system crashes.
Step-by-step solution.
| Feature | File Processing System | DBMS (Database Management System) |
|---|---|---|
| Data Redundancy & Inconsistency | Data is duplicated across multiple separate files. Different copies easily get out of sync. | Centralizes data storage. Normalization avoids duplication and keeps copies consistent. |
| Data Access & Retrieval | Programmers must write a new custom program in C or Java for each new query. | Users write declarative queries (like SQL) to retrieve ad-hoc data quickly without new code. |
| Data Isolation & Independence | Data structures and application code are tightly coupled. Changing a file structure breaks programs. | Provides data abstraction. Changes to physical storage structures do not affect application programs. |
| Concurrent Access & Recovery | Hard to coordinate simultaneous access. Multiple updates cause lost data. Crash recovery is manual. | Built-in concurrency control prevents conflicting updates. Automated logging and recovery preserve ACID properties. |
Variant for 2021 Q.1(a) (4 marks): The same four differences directly answer the question.
Check.
Quick self-test:
Exam tip.
Use a comparison table with clear feature titles. This layout allows the examiner to check off 1 mark per row in seconds.
Sources.
Topic: T02.5 · Design a full E-R diagram for a scenario · Section A
Question. Draw an E-R diagram for RUET student database which can be used to store student's basic information, course advisor's information, subject registration, result information.
Answer.
What the examiner wants.
A complete E-R diagram in Chen notation covering all 4 specified functional areas: student basic info, course advisor, subject registration, and examination results. The diagram must show entities, primary keys underlined, relationships, descriptive attributes, and cardinalities.
Key idea.
Map each requirement to an entity set or relationship. STUDENT connects to ADVISOR through a 1:N relationship, to COURSE through an M:N registration relationship, and to RESULT through a 1:N result relationship.
Step-by-step solution.
Design Specifications:
roll_no. Attributes: name, dept_name, series.advisor_id. Attributes: name, designation, department.course_code. Attributes: course_title, credits.result_id. Attributes: semester, gpa, cgpa.Relationships:
Advises (1:N): An advisor guides multiple students. Each student has one advisor (total participation of student).Registers (M:N): Students register for multiple courses, and courses have many students. Descriptive attributes: session, semester.Obtains (1:N): Each student obtains multiple semester results (total participation of result).
Figure: RUET Student Database Conceptual E-R Diagram
Short version for 2024 Q.1(b) (2 marks):
Draw the 4 entity rectangles (STUDENT, ADVISOR, COURSE, RESULT) and 3 relationship diamonds (Advises, Registers, Obtains) with primary keys underlined (roll_no, advisor_id, course_code, result_id) and cardinality labels (1:N, M:N, 1:N). Omit secondary descriptive attributes to complete within 2 marks.
Check.
Coverage check against requirements:
STUDENT entity with roll_no, name, dept_name, series.ADVISOR entity and Advises relationship.COURSE entity and Registers M:N relationship with semester and session.RESULT entity and Obtains 1:N relationship.Exam tip.
Start by drawing the 4 main entity rectangles in a clean layout. Add the relationship diamonds, then attach the attribute ellipses with keys underlined.
Sources.
Topic: T01.3 · Functions of the DBA and relation schema · Section A (Repeated question: Also asked in 2020 | Solved in T01)
Question. What are the main functions of a database administrator? Point out the name only.
Answer.
What the examiner wants.
The five official functions of a DBA (3 marks, following the exact terminology from Deck 01 Slide 10) and the definition of a relation schema with a formal example (2 marks).
Key idea.
The Database Administrator (DBA) is the person with centralized control over the database system. The DBA handles both physical storage decisions and user authorization. A relation schema is the logical structural definition of a table (its blueprint).
Step-by-step solution.
Five Main Functions of a Database Administrator (DBA):
Relation Schema:
A relation schema is the formal logical definition or blueprint of a relation (table). It specifies the name of the relation along with its set of attributes (columns) and their corresponding domains (data types).
Variant for 2021 Q.1(b) (3 marks): State and explain the five DBA functions above; omit the relation schema.
Variant for 2017 Q.1(c) (2 marks): List only the names: (1) Schema definition, (2) Storage structure and access-method definition, (3) Schema and physical-organization modification, (4) Granting of authorization for data access, (5) Routine maintenance.
Check.
Quick self-test:
Exam tip.
Examiners check off the exact 5 headings from Slide 10. Write the exact headings and underline them.
Sources.
Topic: T04.2 · Write RA queries on a given schema · Section A
Question.
Consider the following relational database.
employee(person_name, street, city)
works(person_name, company_name, salary)
company(company_name, city)
manages(person_name, manager_name)
Now write down the relational algebra(Not SQL) to express each of following queries:
(i) Find the names of all employees who live in the city same as their corresponding company location.
(ii) Give a 10% salary raise to all the managers only.
(iii) Update the city information of the employee named "James" to "Newtown".
(iv) Find the company with most employees.
Answer.
What the examiner wants.
Four distinct relational algebra expressions worth 2 marks each. The question tests natural joins across three tables. It also tests tuple updates using generalized projection and set union, attribute assignment, and aggregation with max filtering.
Key idea.
Relational algebra expressions manipulate relation instances as mathematical sets. For updates, standard relational algebra has no in-place mutation. We express updates by computing the modified tuples and taking their union with the untouched tuples. For aggregation, group by company and find the peak count.
Step-by-step solution.
(i) Employees living in the same city as their company:
employee with works on person_name. This matches each person with their employer.company. Both employee and company share the attribute city, while works and company share company_name. The natural join ⋈ automatically enforces employee.city = company.city and works.company_name = company.company_name.person_name:Equivalently, written as a single expression:
Πperson_name(employee⋈works⋈company)(ii) Give a 10% salary raise to all managers only:
manages relation pairs (person_name, manager_name). Extract all distinct manager names and rename the attribute to person_name to join with works:works as the union of raised and untouched records:(iii) Update city of employee "James" to "Newtown":
"Newtown":(iv) Find the company with the most employees:
works relation by company_name and count the employees:Check.
Consider sample data:
employee: ("Alice", "Road 1", "Dhaka"), ("Bob", "Road 2", "Rajshahi").
works: ("Alice", "Apex", 50000), ("Bob", "Apex", 45000).
company: ("Apex", "Dhaka").
manages: ("Bob", "Alice").
Part (i): Alice lives in Dhaka and Apex is in Dhaka. Bob lives in Rajshahi. Natural join returns ("Alice").
Part (ii): Alice is in manages.manager_name. Alice gets 50000×1.1=55000. Bob is untouched at 45000. The union restores both employees.
Part (iv): Apex has count 2. Max count is 2. The selection matches Apex.
Exam tip.
Break long relational algebra queries into named temporary relations using ←. It prevents syntax errors and earns partial marks even if an index is misnamed.
Sources.
[Lecture Deck 02 · Slides 15–29](../LectureSlides/02_Relational_Model.md)
[Textbook Ch. 2 §2.6](../Textbook/Chapter_02_Relational_Model/Chapter%2002%20-%20Introduction%20to%20the%20Relational%20Model.md)
[Textbook Ch. 16 §16.1](../Textbook/Chapter_16_Query_Optimization/Chapter%2016%20-%20Query%20Optimization.md)
Topic: T01.4 · Data abstraction levels, schemas and instances · Section A
Question. What is the purpose of data abstraction? Describe the different level of data abstraction.
Answer.
What the examiner wants.
The definition and purpose of data abstraction (~1 mark), clear descriptions of all three abstraction levels (physical, logical, view) (~2 marks), and the architecture diagram (~1 mark).
Key idea.
Database systems use complex data structures to store information efficiently. Most users and application programmers do not understand storage pointers or disk block layouts. Data abstraction hides low-level complexity to provide a clean and intuitive interface.
Step-by-step solution.
Purpose of Data Abstraction:
A database contains complex data structures, storage blocks, and indexing schemes. Most end users and programmers are not trained in low-level storage details. Data abstraction hides this physical complexity. It simplifies user interactions, enforces security, and enables physical data independence.
Levels of Data Abstraction:
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
Figure: Three levels of data abstraction (Deck 01, Slide 14)
Variant for 2019 Q.2(a) (4 marks): Define data abstraction, describe the three levels, and include the diagram.
Variant for CT-01 Q.01 (5 marks): State the definition, explain the three levels, show the record example, and draw the diagram.
Check.
Quick level-matching test:
Exam tip.
Draw the three-tiered box diagram with multiple view boxes on top, the logical box in the middle, and the physical box at the bottom.
Sources.
Topic: T08.6 · Define normalization (and its importance) & 1NF / 2NF / 3NF · Section A
Question. What do you mean by normalization? Why normalization is important for database?
Answer.
What the examiner wants.
A concise definition of normalization (1.5 marks) and four clear points on why it is important for relational database design (1.5 marks).
Key idea.
Normalization is systematic database cleanup. It takes messy, bloated tables and divides them into well-behaved tables where every non-key column depends strictly on the primary key.
Step-by-step solution.
Normalization is a formal, systematic technique for designing relational database schemas. It decomposes relations with anomalies into smaller, well-structured relations to reduce data redundancy and ensure data integrity.
Normalization is essential for relational databases because it:
Short version for CT-03 Q.03 (3 marks): Define normalization as the systematic decomposition of relations to minimize redundancy and eliminate anomalies. State the main objective: to produce well-structured tables free of insertion, update, and deletion anomalies while maintaining data consistency.
Check.
Quick self-test:
Exam tip.
Provide the formal definition in 2 to 3 lines, followed by a numbered list of four distinct benefits.
Sources.
Topic: T08.8 · Normalize an unnormalized table → 1NF → 2NF → 3NF · Section A
Question.
Consider the following data table com_employee. Is it already normalized? If not then normalize the table com_employee up to 3rd normal form.
com_employee
| Pcode | Ptitle | EmpNo | EmName | EmCon | dNo | dName | HRate |
|---|---|---|---|---|---|---|---|
| p1 | Admission Test System | E1 | Jones | 501, 502 | D1 | IT | 1000 |
| p1 | Admission Test System | E3 | Smith | 505 | D2 | Database | 1100 |
| p1 | Admission Test System | E4 | James | 508, 509 | D3 | HR | 800 |
| p2 | Salary System | E1 | Jones | 501, 502 | D1 | IT | 900 |
| p2 | Salary System | E3 | Smith | 505 | D2 | Database | 1000 |
Answer.
What the examiner wants.
Direct answer on normalization status with justification (1 mark), followed by a clear, progressive three-step transformation: 1NF with atomic rows and primary key (2.5 marks), 2NF eliminating partial dependencies (2.5 marks), and 3NF eliminating transitive dependencies with sample tables and keys (3 marks).
Key idea.
Notice that EmCon has comma-separated contact numbers (violates 1NF). Next, project titles depend only on Pcode, and employee names depend only on EmpNo (violates 2NF). Finally, department name depends on dNo, which depends on EmpNo (violates 3NF).
Step-by-step solution.
No, the table is not normalized.
It contains multi-valued entries in column EmCon (501, 502 and 508, 509). This directly violates the atomicity requirement of First Normal Form (1NF). In addition, it mixes project, employee, contact, department, and assignment facts, causing partial and transitive dependencies.
EmpNo).To achieve 1NF, we eliminate multi-valued fields by splitting them into separate atomic rows:
| Pcode | Ptitle | EmpNo | EmName | EmCon | dNo | dName | HRate |
|---|---|---|---|---|---|---|---|
| p1 | Admission Test System | E1 | Jones | 501 | D1 | IT | 1000 |
| p1 | Admission Test System | E1 | Jones | 502 | D1 | IT | 1000 |
| p1 | Admission Test System | E3 | Smith | 505 | D2 | Database | 1100 |
| p1 | Admission Test System | E4 | James | 508 | D3 | HR | 800 |
| p1 | Admission Test System | E4 | James | 509 | D3 | HR | 800 |
| p2 | Salary System | E1 | Jones | 501 | D1 | IT | 900 |
| p2 | Salary System | E1 | Jones | 502 | D1 | IT | 900 |
| p2 | Salary System | E3 | Smith | 505 | D2 | Database | 1000 |
PK: (Pcode, EmpNo, EmCon)
We eliminate partial dependencies where non-prime attributes depend on proper subsets of the composite key:
Pcode -> Ptitle depends only on Pcode.EmpNo -> EmName, dNo, dName depends only on EmpNo.(EmpNo, EmCon) represents employee phone numbers.(Pcode, EmpNo) -> HRate depends on the full project-employee assignment.We decompose into four 2NF relations:
PROJECT
| Pcode | Ptitle |
|---|---|
| p1 | Admission Test System |
| p2 | Salary System |
PK: Pcode
EMPLOYEE_2NF
| EmpNo | EmName | dNo | dName |
|---|---|---|---|
| E1 | Jones | D1 | IT |
| E3 | Smith | D2 | Database |
| E4 | James | D3 | HR |
PK: EmpNo
EMP_CONTACT
| EmpNo | EmCon |
|---|---|
| E1 | 501 |
| E1 | 502 |
| E3 | 505 |
| E4 | 508 |
| E4 | 509 |
PK: (EmpNo, EmCon)
PROJECT_ASSIGNMENT
| Pcode | EmpNo | HRate |
|---|---|---|
| p1 | E1 | 1000 |
| p1 | E3 | 1100 |
| p1 | E4 | 800 |
| p2 | E1 | 900 |
| p2 | E3 | 1000 |
PK: (Pcode, EmpNo)
In EMPLOYEE_2NF, a transitive dependency exists:
Here, dNo is a non-prime attribute determining another non-prime attribute dName.
We decompose EMPLOYEE_2NF into:
DEPARTMENT(dNo, dName) with PK dNo.EMPLOYEE(EmpNo, EmName, dNo) with PK EmpNo and foreign key dNo referencing DEPARTMENT.PROJECT
PROJECT(Pcode, Ptitle)
PK: Pcode
DEPARTMENT
| dNo | dName |
|---|---|
| D1 | IT |
| D2 | Database |
| D3 | HR |
PK: dNo
EMPLOYEE
| EmpNo | EmName | dNo |
|---|---|---|
| E1 | Jones | D1 |
| E3 | Smith | D2 |
| E4 | James | D3 |
PK: EmpNo | FK: dNo references DEPARTMENT(dNo)
EMP_CONTACT
EMP_CONTACT(EmpNo, EmCon)
PK: (EmpNo, EmCon) | FK: EmpNo references EMPLOYEE(EmpNo)
PROJECT_ASSIGNMENT
PROJECT_ASSIGNMENT(Pcode, EmpNo, HRate)
PK: (Pcode, EmpNo) | FKs: Pcode references PROJECT(Pcode), EmpNo references EMPLOYEE(EmpNo)
Check.
Trace check:
PROJECT_ASSIGNMENT (p1, E1, 1000) with PROJECT (p1, Admission Test System) and EMPLOYEE (E1, Jones, D1). The rate is 1000.E1 -> D1 -> IT. It matches the original table perfectly.Exam tip.
State the functional dependencies at the top before writing any tables. This justifies every table split to the examiner.
Sources.
Topic: T05.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · Section A
Question.
Considering following tables (INFO, MARKS, CREDIT) answer (i),(ii) & (iii).
INFO
| MARKS
| CREDIT
|
Answer.
What the examiner wants.
Three distinct SQL capabilities (3 marks each):
Key idea.
In relational database design, bridge tables like MARKS contain foreign keys pointing to independent parent entities (INFO and CREDIT). Calculating CGPA requires joining grade points with course credits, taking their products, summing them per student, and dividing by total enrolled credit units.
Step-by-step solution.
(i) Create table MARKS:
CREATE TABLE MARKS (
roll INT,
sub_code VARCHAR(20),
gpa DECIMAL(3, 2),
PRIMARY KEY (roll, sub_code),
FOREIGN KEY (roll) REFERENCES INFO(roll),
FOREIGN KEY (sub_code) REFERENCES CREDIT(sub_code)
);
(ii) Subject code and GPA for student with class serial 02:
Assumption: In the RUET roll format (e.g., 1710002), the final two digits represent the student's class serial. Class serial 02 identifies student roll 1710002 (Oliver).
SELECT sub_code, gpa
FROM MARKS
WHERE roll = 1710002;
(Alternative dynamic filter matching the last two digits: WHERE roll % 100 = 2;)
(iii) Calculate CGPA of each student:
SELECT m.roll,
SUM(m.gpa * c.credit) / SUM(c.credit) AS cgpa
FROM MARKS m
JOIN CREDIT c ON m.sub_code = c.sub_code
GROUP BY m.roll;
Check.
Manual trace for student Oliver (roll = 1710002):
Exam tip.
Explicitly state your interpretation of "class serial 02" in one short assumption line before writing the query.
Sources.
Deck 03 · Slides 7–10, 18, 30–33, Textbook Ch. 3 §3.2, §3.4, §3.7.
Topic: T09.1 · ACID properties · Section B
Question. Briefly discuss the ACID properties of transaction.
Answer.
What the examiner wants.
A concise definition of each of the four ACID properties. Examiners look for the specific database subsystem responsible for enforcing each property. The mark split is 1 mark per property (or 0.5 marks each in the 2-mark paper).
Key idea.
A transaction is a logical unit of database work. To keep data safe during crashes and concurrent access, the DBMS treats every transaction as an atomic, isolated unit that leaves data consistent and permanently saved.
Step-by-step solution.
A transaction is a logical unit of program execution that accesses and updates data items. To preserve data integrity during crashes and concurrent access, the DBMS must ensure the four ACID properties:
Atomicity ("All-or-None"):
Consistency (Preservation of Invariants):
Isolation (Shielding Concurrent Access):
Durability (Persistence):
Short version for 2024 Q.6(c) (2 marks):
Check.
Quick self-test:
Exam tip.
Start each bullet with the letter of the acronym, bold the property name, write a one-sentence definition, and end by naming the enforcing component.
Sources.
Topic: T10.1 · Define conflicting instructions & conflict serializability · Section B
Question. What do you know about conflict serializability?
Answer.
What the examiner wants. A crisp definition of conflict serializability (1 mark) and the rule identifying conflicting operations or graph testing (1 mark).
Key idea. A serial schedule executes transactions one after another with no overlap. It is inherently safe. A concurrent schedule interleaves operations from different transactions. If we can rearrange that concurrent schedule into a serial schedule by only swapping adjacent instructions that do not interfere with each other, the concurrent schedule is just as safe as the serial schedule. We call such a schedule conflict serializable.
Step-by-step solution.
Check.
Exam tip. For a 2-mark question, write the definition of conflict serializability and list the 4 read/write cases in 3 to 4 lines.
Sources.
Topic: [[Topicwise_answers_explaination/T10_Serializability.md#T10.4 · Build serializable/non-serializable schedules (T1,T2 with "if A = 0 then B := B+1")|T10.4 · Build serializable/non-serializable schedules (T1,T2 with "if A = 0 then B := B+1")]] · Section B
Question.
Consider the following two transactions.
T1:
read(A);
read(B);
if A = 0 then B:=B+1;
write(B);
T2:
read(B);
read(A);
if B = 0 then A:=A+1;
write(A);
Let the consistency requirement be A=0 or B=0 with A=B=0 the initial values.
(i) Show a concurrent execution of T1 and T2 that produces a nonserializable schedule.
(ii) Is there a concurrent execution of T1 and T2 that produces a serializable schedule?
Answer.
What the examiner wants. Baseline analysis of serial executions (1 mark), constructing an interleaved schedule and proving inconsistency and non-serializability (3 marks), and rigorous proof that no concurrent execution can be serializable (2 marks).
Key idea. T1 increments B only if A=0. T2 increments A only if B=0. If they run serially, whichever runs first changes its target variable from 0 to 1. The second transaction then sees a non-zero value and does not change its variable. One variable becomes 1 while the other remains 0, preserving consistency (A=0∨B=0). But if they interleave so that both read before either writes, both see 0. Both increment their variables, resulting in A=1,B=1. That violates consistency and forms a cycle.
Step-by-step solution.
Initial state: A=0,B=0. Consistency requirement: A=0∨B=0.
B = 0 is false (1=0). It does not increment A. It writes A=0.A = 0 is false (1=0). It does not increment B. It writes B=0.We construct a schedule where both transactions read both items before either performs its write:
| Step | Transaction | Instruction | Value Read / Action |
|---|---|---|---|
| 1 | T1 | read(A); | Reads initial value A=0 |
| 2 | T2 | read(B); | Reads initial value B=0 |
| 3 | T1 | read(B); | Reads initial value B=0 |
| 4 | T2 | read(A); | Reads initial value A=0 |
| 5 | T1 | if A = 0 then B:=B+1;write(B); | A=0 is true ⟹B:=0+1=1. Writes B=1. |
| 6 | T2 | if B = 0 then A:=A+1;write(A); | B=0 is true ⟹A:=0+1=1. Writes A=1. |
Final Database State:
A=1andB=1This violates the consistency requirement A=0∨B=0 because neither A nor B is 0.

Proof of Non-serializability:
Answer: No.
Proof: In a genuinely concurrent (interleaved) execution, the instructions of T1 and T2 must overlap in time:
write(A) is T2's final operation). But if T2 finishes before T1 starts reading A, T2 executed serially before T1.write(B) is T1's final operation). But if T1 finishes before T2 starts reading B, T1 executed serially before T2.For any schedule that is truly interleaved (concurrent), T1 must read A before T2 writes A, and T2 must read B before T1 writes B. This forces both directed edges:
T1⟶T2andT2⟶T1This creates a cycle T1⟷T2 in every concurrent execution. Therefore, every concurrent execution is non-serializable. Only strictly serial executions (⟨T1,T2⟩ and ⟨T2,T1⟩) are serializable.
Check.
Exam tip. This is Silberschatz Exercise 17.15. Remembering the final result (A=1,B=1) and the cycle T1↔T2 allows you to write the answer quickly.
Sources.
Topic: T02.7 · EER: specialization / generalization · Section B
Question. Write short note on specialization and generalization in DBMS.
Answer.
What the examiner wants.
A concise conceptual note defining specialization (top-down) and generalization (bottom-up), noting attribute inheritance, and giving a quick example (2 marks).
Key idea.
Specialization breaks a high-level entity into specialized sub-groups. Generalization combines multiple lower-level entities sharing traits into a broader category. Both use the ISA triangle in E-R diagrams.
Step-by-step solution.
Specialization (Top-down):
A top-down design process. A higher-level entity set is divided into lower-level entity sets that have distinctive attributes or participate in specific relationships.
person specialized into employee and student.Generalization (Bottom-up):
A bottom-up design process. Multiple lower-level entity sets sharing common properties are synthesized into a single higher-level entity set.
instructor and secretary into employee.Key Properties:
Figure: Specialization Hierarchy Example (Deck 05, Slide 51)
Check.
Quick self-test:
Exam tip.
State "Top-down" for specialization and "Bottom-up" for generalization in your very first sentence.
Sources.
Topic: T11.2 · Two-phase locking: growing/shrinking phases, lock point, inserting lock/unlock instructions · Section B
Question. How concurrent execution of transactions are controlled using two phase based locking protocol? Briefly discuss with an example.
Answer.
What the examiner wants.
The examiner wants the definition of Two-Phase Locking (2PL), descriptions of the two phases, the definition of lock point, and a clean concrete example. The expected mark split is 1 mark for the phase definitions, 1 mark for lock point and serializability guarantee, and 2 marks for the worked example.
Key idea.
Simple locking allows a transaction to acquire and release locks at any time. But simple locking can create non-serializable schedules. 2PL solves this. It divides lock handling into two separate phases. In phase one, a transaction only grabs locks. In phase two, it only lets them go. Once a transaction drops a lock, it can never grab another. This rule guarantees conflict serializability.
Step-by-step solution.
The Two-Phase Locking (2PL) protocol controls concurrent transactions by enforcing two sequential phases:
lock-S or lock-X).unlock).Lock Point:
The moment the transaction acquires its final lock is its lock point. Once this point passes, unlocking begins. The order of lock points determines the equivalent serial execution order.

Figure: Two-Phase Locking Protocol (Source: Deck 08, Slide 13)
Example:
Consider transaction T1 reading A and updating B:
lock-S(A); -- Growing phase begins
read(A);
lock-X(B); -- Lock point (last lock acquired)
read(B);
B := B - 50;
write(B);
unlock(A); -- Shrinking phase begins (no more locks allowed)
unlock(B); -- Final unlock
Because all locks are acquired before any lock is released, T1 obeys 2PL.
Check.
Quick self-test:
Exam tip.
Draw the trapezoidal locks vs time diagram from Deck 08 Slide 13. Label the growing phase, peak lock point, and shrinking phase clearly.
Sources.
Topic: T12.1 · Failure classification, precautions, recovery methods · Section B
Question. Classify and discuss the failures in DBMS.
Answer.
What the examiner wants.
The three fundamental failure classes in a DBMS: transaction failure, system crash, and disk failure. Examiners look for the affected storage medium and a 1-mark split per class.
Key idea.
Different components fail differently. Main memory is volatile and loses data on power loss. Disk drives are non-volatile and survive power loss, but suffer physical media damage. Transactions can fail internally even when all hardware is operating normally.
Step-by-step solution.
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.
Check.
Quick self-test:
Exam tip.
Structure the answer clearly into three numbered tiers: transaction logic, volatile memory (system crash), and non-volatile disk media.
Sources.
Topic: T12.3 · Log-based recovery and shadow paging · Section B
Question. Discuss shortly the log-based recovery approach to ensure atomicity despite of failures of DBMS.
Answer.
What the examiner wants.
An explanation of how log-based recovery enforces atomicity. Key concepts include structured log records on stable storage, the Write-Ahead Logging (WAL) protocol, and undo processing.
Key idea.
To guarantee that an incomplete transaction leaves no trace, the DBMS must record old data values on stable storage before modifying data pages. If a failure occurs, the recovery manager reads these old values to undo partial updates.
Step-by-step solution.
Log-based recovery ensures atomicity by recording every database update in an append-only log on stable storage before modifying the actual database on disk.
Check.
Quick self-test:
Exam tip.
Highlight the WAL rule clearly and explicitly state that atomicity is achieved by using the old value (V1) during transaction rollback.
Sources.
Topic: T11.2 · Two-phase locking: growing/shrinking phases, lock point, inserting lock/unlock instructions · Section B
Question.
What is starvation? Consider the following two transactions.
T1:
read(A);
read(B);
if A = 0 then B:=B+15% of B;
write(B);
T2:
read(B);
read(A);
if B = 0 then A:=A+20% of A;
write(A);
Add lock and unlock instructions to transaction T1 and T2, so that they observe the two phase locking protocol. Can the execution of these transactions result in a deadlock? Justify.
Answer.
What the examiner wants.
This 5-mark question has three distinct components:
lock-S, lock-X, and unlock instructions into both transactions following 2PL rules (2 marks).Key idea.
Starvation happens when a transaction waits forever because other transactions keep jumping ahead with compatible locks. Under 2PL, a transaction must grab all locks before releasing any. T1 accesses A then B, while T2 accesses B then A. If T1 locks A and T2 locks B, each transaction holds what the other wants next. Both wait forever. So 2PL does not prevent deadlock.
Step-by-step solution.
1. Starvation:
Starvation occurs when a transaction waits indefinitely for a lock on a data item. This happens when other transactions keep requesting and receiving compatible locks on that same item. The waiting transaction cannot proceed.
2. Inserting 2PL Lock and Unlock Instructions:
lock-S(A)), reads B, and conditionally writes B (needs lock-X(B)).lock-S(B)), reads A, and conditionally writes A (needs lock-X(A)).Transaction T1 with 2PL instructions:
lock-S(A);
read(A);
lock-X(B);
read(B);
if A = 0 then B := B + 15% of B;
write(B);
unlock(A);
unlock(B);
Transaction T2 with 2PL instructions:
lock-S(B);
read(B);
lock-X(A);
read(A);
if B = 0 then A := A + 20% of A;
write(A);
unlock(B);
unlock(A);
3. Deadlock Analysis and Justification:
Yes, the execution of these transactions can result in a deadlock.
Justification:
Consider the following concurrent interleaving:
lock-S(A) and read(A). T1 holds a shared lock on A.lock-S(B) and read(B). T2 holds a shared lock on B.lock-X(B). Because exclusive mode conflicts with shared mode (by the lock-compatibility matrix, S and X are incompatible), T1 must wait for T2 to release B.lock-X(A). Because exclusive mode conflicts with shared mode (by the lock-compatibility matrix, S and X are incompatible), T2 must wait for T1 to release A.At this point, T1 is waiting for T2, and T2 is waiting for T1. Under 2PL, neither transaction can unlock a data item during its growing phase. A circular wait forms:
Cycle: T1→T2→T1Neither transaction can make progress. Thus, the system is deadlocked.

Figure: Interleaved execution and wait-for graph cycle producing deadlock between T1 and T2 under 2PL
Check.
Trace check:
In T1, locks are acquired at lines 1 and 3; unlocks occur at lines 7 and 8. No lock occurs after an unlock. 2PL is verified.
In T2, locks are acquired at lines 1 and 3; unlocks occur at lines 7 and 8. No lock occurs after an unlock. 2PL is verified.
Cross-locking conflict: T1 holds A, requests B. T2 holds B, requests A. Cycle exists ⟹ deadlock confirmed.
Lock-Compatibility Matrix:
| S | X | |
|---|---|---|
| S | Compatible (True) | Incompatible (False) |
| X | Incompatible (False) | Incompatible (False) |
| Shared locks are mutually compatible (S−S). Any request involving an exclusive lock (S−X,X−S,X−X) conflicts, forcing the requesting transaction to wait. |
Lock upgrade alternative: If T1 initially acquired lock-S(B) and upgraded to lock-X(B) before writing, the upgrade must occur within the growing phase. But because T2 concurrently holds lock-S(B), T1's upgrade request is blocked, leading to the same deadlock.
Exam tip.
Always list the 4-step interleaving in your answer. Showing T1 holding A while waiting for B, and T2 holding B while waiting for A, gives the examiner complete proof.
Sources.
Topic: T11.4 · Deadlock: conditions, prevention vs detection, wait-for graph, victim selection · Section B
Question. Define deadlock. Explain how deadlock is prevented?
Answer.
What the examiner wants.
The definition of deadlock in database systems (1 mark), followed by a clear explanation of the main deadlock prevention approaches: lock pre-declaration, lock ordering, timestamp-based schemes (wait-die and wound-wait), and timeout mechanisms (3 marks).
Key idea.
A deadlock is a traffic jam of transactions. Transaction A holds item 1 and waits for item 2. Transaction B holds item 2 and waits for item 1. Neither can move. Deadlock prevention stops this before it can happen. The system either forces transactions to lock everything upfront, locks items in strict numerical order, or uses timestamps to abort transactions that might cause a cycle.
Step-by-step solution.
1. Deadlock Definition:
A deadlock is an execution state where two or more transactions wait indefinitely for data locks held by one another. None can proceed without external intervention.
2. Deadlock Prevention Methods:
Deadlock prevention protocols guarantee that the system will never enter a deadlock state. Four primary methods are used:
Pre-declaration (Pre-claiming All Locks):
Each transaction must request and receive all its locks at once before execution begins. If even one data item is unavailable, no locks are granted and the transaction waits.
Drawbacks: It is hard to know all required data items in advance. Resource usage is low because data items remain locked while idle.
Lock Ordering:
The system establishes a global ordering on all data items (d1<d2<⋯<dn). Transactions must request locks strictly in ascending order. Since all transactions request items in the same sequence, circular waits cannot form.
Timestamp-Based Preemption Schemes:
Each transaction receives a unique timestamp TS on arrival. When transaction Ti requests an item held by Tj:
| Scheme | Older requests item from Younger | Younger requests item from Older | Type |
|---|---|---|---|
| Wait-Die | Older waits | Younger dies (rolls back) | Non-preemptive |
| Wound-Wait | Older wounds younger (rolls back younger) | Younger waits | Preemptive |
Timeout-Based Scheme:
A transaction waits for a requested lock only for a predefined timeout duration. If the lock is not granted in time, the transaction times out and rolls back. This prevents permanent deadlocks.

Figure: Wait-for Graph with a cycle indicating deadlock (Source: Deck 08, Slide 24)
Check.
Quick self-test:
Exam tip.
Include the comparison table for wait-die vs wound-wait. Examiners frequently look for these exact conditions when grading deadlock prevention.
Sources.
Topic: T13.4 · Hashing: static vs dynamic · Section B
Question. What is hashing? Differentiate between static and dynamic hashing.
Answer.
What the examiner wants.
A precise definition of hashing (1 mark) and at least four distinct differences between static and dynamic hashing (2 marks).
Key idea.
Static hashing fixes the number of buckets up front. If the database outgrows that estimate, overflow buckets chain together like linked lists, slowing down lookups. Dynamic hashing (such as extendable hashing) uses a directory of bucket pointers. When a bucket fills up, only that single bucket splits, and the directory doubles in size if needed.
Step-by-step solution.
1. What is Hashing?
Hashing is a search and data organization technique. It uses a mathematical function h(K), called a hash function. The function maps a search key K to the address of the bucket storing the record. A bucket is a storage unit, typically a disk block. Hashing provides direct O(1) average search time for equality queries without traversing tree pointers.
2. Differentiate between Static and Dynamic Hashing
| Feature | Static Hashing | Dynamic Hashing |
|---|---|---|
| Number of Buckets | Fixed at database creation time. | Adjusts dynamically as the database grows or shrinks. |
| Overflow Handling | Uses overflow bucket chains when a bucket fills up. | Buckets split or coalesce. Overflow chains are avoided or minimized. |
| Lookup Performance | Degrades over time. Long overflow chains require slow sequential scans. | Remains fast (O(1) disk accesses) even after substantial growth. |
| Reorganization | Requires periodic offline rebuilding of the whole file with a new hash function. | Reorganizes incrementally, one bucket at a time, without stopping database access. |
| Space Usage | Poor. Allocating few buckets causes overflow; allocating many wastes space. | High. Storage capacity scales smoothly with the actual number of records. |
| Common Examples | Modulo hashing with overflow chaining. | Extendable hashing and linear hashing. |
Figure 13.3: General extendable hash structure with bucket address table (Source: Textbook Ch. 24, Fig. 24.8).
Check.
How Extendable Hashing handles overflow:
Quick self-test:
salary BETWEEN 50000 AND 80000). Hash functions scatter adjacent keys randomly across buckets.Exam tip.
Define hashing first with the formula h(K)→B, then present the comparison table with bucket count, overflow handling, performance, and reorganization.
Sources.
[Textbook Ch. 14 §14.5](../Textbook/Chapter_14_Indexing/Chapter%2014%20-%20Indexing.md)
[Textbook Ch. 24 §24.5](../Textbook/Chapter_24_Advanced_Indexing/Chapter%2024%20-%20Advanced%20Indexing%20Techniques.md)
Topic: T13.1 · Database security threats and authorization · Section B
Question. Describe four of the main threats to database security.
Answer.
What the examiner wants.
Four distinct threats to database security with 1 mark allocated per threat. The examiner looks for the core threat mechanism and a concrete technical countermeasure for each.
Key idea.
Database security protects data confidentiality, integrity, and availability. Threats can target application inputs, user privileges, network transit, or system availability. A good defense uses defense-in-depth across the application, DBMS, and network.
Step-by-step solution.
Four main threats to database security and their countermeasures are:
SQL Injection:
Privilege Abuse and Unauthorized Access:
GRANT/REVOKE) and restricted SQL views.Data Eavesdropping and Leakage:
Denial of Service (DoS):
Check.
Quick self-test:
Exam tip.
Write exactly four points. Give one clear line explaining the threat and one line giving the countermeasure to score the full 4 marks quickly.
Sources.
[Textbook Ch. 9 §9.8](../Textbook/Chapter_09_App_Development/Chapter%2009%20-%20Application%20Development.md)
[Textbook Ch. 4 §4.7](../Textbook/Chapter_04_Intermediate_SQL/Chapter%2004%20-%20Intermediate%20SQL.md)
[LectureSlides Deck 01 · Slide 22–23](../LectureSlides/01_Intro_to_Database_and_DBMS.md)
Topic: T07.2 · Triggers for security before and after a breach · Section B
Question. Using examples, discuss how Trigger can contribute to the security of database, before and after a security breach.
Answer.
What the examiner wants.
A structured analysis of database security in two distinct operational phases: prevention before a breach (2.5 marks) and auditing or forensics after a breach (2.5 marks). Both parts must provide practical SQL trigger examples.
Key idea.
Think of BEFORE triggers as security guards stationed at the door. They check identity and inspect the request before letting changes touch the table. If anything looks wrong, they block the action on the spot. Think of AFTER triggers as security cameras. Once an action takes place, they record an unalterable log of who did what and when. This allows investigators to analyze the damage later.
Step-by-step solution.
Triggers protect database security at two stages: proactive prevention before a breach and forensic auditing after a breach.
BEFORE triggers act as real-time security gatekeepers. They evaluate incoming data modifications before changes reach the database.
SIGNAL SQLSTATE '45000'.Example (Blocking salary changes outside working hours):
DELIMITER //
CREATE TRIGGER trg_prevent_unauthorized_salary_update
BEFORE UPDATE ON employees
FOR EACH ROW
BEGIN
IF NEW.salary <> OLD.salary THEN
IF CURRENT_TIME() NOT BETWEEN '09:00:00' AND '17:00:00' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Security Alert: Salary edits outside office hours are blocked';
END IF;
END IF;
END //
DELIMITER ;
AFTER triggers execute immediately after a modification succeeds on a table.
AFTER triggers write the unauthorized changes into an independent audit log table.USER(), NOW(), the modified table, and both OLD and NEW column values.Example (Logging security role modifications):
DELIMITER //
CREATE TRIGGER trg_audit_role_change
AFTER UPDATE ON user_roles
FOR EACH ROW
BEGIN
IF OLD.role <> NEW.role THEN
INSERT INTO security_audit_log (
user_id, old_role, new_role, changed_by, changed_at
) VALUES (
OLD.user_id, OLD.role, NEW.role, USER(), NOW()
);
END IF;
END //
DELIMITER ;
Short version for 2024 Q.2(a) (3 marks): State how BEFORE triggers block unauthorized actions with SIGNAL and how AFTER triggers record tamper-evident audit logs with USER() and timestamps. Provide one concise trigger example.
Check.
Execution trace comparison:
UPDATE employees SET salary = salary + 5000 WHERE employee_id = 101; at 20:30.BEFORE UPDATE trigger checks CURRENT_TIME(). The time falls outside the 09:00 to 17:00 window. The trigger raises SIGNAL SQLSTATE '45000'. The database rolls back the transaction. The database table remains completely untouched.UPDATE user_roles SET role = 'admin' WHERE user_id = 42;.AFTER UPDATE trigger immediately fires and inserts (42, 'user', 'admin', 'attacker_session', '2026-10-30 14:15:00') into security_audit_log. The administrator queries this log to detect the breach, identify the compromised account, and revert the unauthorized role change.Exam tip.
Split your answer cleanly into two bold sections: "Before a Breach (Prevention via BEFORE Triggers)" and "After a Breach (Auditing and Forensics via AFTER Triggers)". Provide one short SQL example for each section.
Sources.
Topic: T08.6 · Define normalization (and its importance) & 1NF / 2NF / 3NF · Section B
Question. What is 1NF, 2NF and 3NF?
Answer.
What the examiner wants.
Accurate, concise definitions for 1NF, 2NF, and 3NF, highlighting the primary defect each normal form eliminates (1 mark per normal form).
Key idea.
Step-by-step solution.
First Normal Form (1NF):
A relation is in 1NF if and only if every attribute domain contains only atomic (indivisible) values, and each cell contains exactly one value. It strictly disallows multi-valued attributes, composite attributes, and repeating groups.
Second Normal Form (2NF):
A relation is in 2NF if and only if:
Third Normal Form (3NF):
A relation is in 3NF if and only if:
Check.
Quick self-test:
Exam tip.
For a 3-mark question, spend exactly one concise paragraph on each normal form. Highlight the key terms: atomic values, no partial dependencies, and no transitive dependencies.
Sources.
← Directory Overview | Exam-Style Layer | Original Question Paper | Next: 2018 →