88.7 KB · commit 40bb182
| year | 2018 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2018 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 72 |
| time | 3 Hours |
| layer | explanation |
← Prev: 2017 | Exam-Style Layer | Original Question Paper | Next: 2019 →
Topic: T01.2 · File system vs DBMS · Section A
Question. "A database is a tool for storing information efficiently"- Justify this statement.
Answer.
What the examiner wants.
A clear technical justification showing how a database achieves efficiency. The expected mark split is 1 mark for each of the three dimensions of efficiency: storage space, retrieval speed, and operational concurrency.
Key idea.
Efficiency means doing more while using fewer resources. Storing data in raw files wastes storage space through duplicate records and wastes time because lookups require scanning whole files. A database solves these issues with normalization, indexing, and multi-user transaction management.
Step-by-step solution.
A database stores information efficiently by removing the major storage and access bottlenecks of traditional file systems:
Check.
Quick self-test:
Exam tip.
Divide the answer into three clear headings: Storage Efficiency, Retrieval Efficiency, and Operational Efficiency.
Sources.
Topic: T02.4 · Weak vs strong entity sets · Section A
Question. Define entity set. Explain the following with suitable example: (i) strong entity set and (ii) weak entity set.
Answer.
What the examiner wants.
Definition of an entity set (1 mark). Comprehensive comparison and explanation of strong vs weak entity sets (2 marks). Concrete examples showing the identifying relationship, discriminator, and composite primary key (1 mark).
Key idea.
A strong entity set has enough attributes to tell every record apart. A weak entity set does not. A weak entity depends on an owner entity for its existence and identity. Its key is formed by taking the owner's primary key and attaching its own partial key (discriminator).
Step-by-step solution.
Entity Set:
An entity set is a collection of entities of the same type that share the same properties or attributes (e.g., the set of all students in a university).
| Feature | Strong Entity Set | Weak Entity Set |
|---|---|---|
| Primary Key | Has sufficient attributes to form its own primary key. | Lacks a primary key of its own. Uses a partial key (discriminator). |
| Existence Dependency | Independent. Does not depend on another entity set. | Existence-dependent on an identifying (strong) entity set. |
| E-R Notation | Single rectangle. | Double rectangle. |
| Relationship Set | Connected via regular relationship (single diamond). | Connected via identifying relationship (double diamond). |
| Discriminator Key | None (uses full primary key underlined with solid line). | Has a discriminator underlined with a dashed line. |
| Composite PK | Its own primary key. | Formed by (Owner Primary Key + Discriminator). |
| Example | course with primary key course_id. | section with discriminator sec_id, semester, year. |
Figure: Expressing Weak Entity Sets in ER Diagram (Deck 05, Slide 37)
course has attributes course_id (PK), title, credits. It exists independently.section has attributes sec_id, semester, year. A section number like Sec 1 is meaningless without knowing the course. Its full primary key is (course_id, sec_id, semester, year).Short version for 2020 Q.2(c) and 2021 Q.8(c) (2 marks):
State the comparison table rows (Primary Key, Dependency, Notation, Example) and omit the separate entity set definition.
Check.
Quick self-test:
Exam tip.
Always mention the standard textbook example (course and section). Show the exact composite primary key formula.
Sources.
Topic: T02.5 · Design a full E-R diagram for a scenario · Section A
Question. What is E-R model? Draw an E-R diagram that includes teacher, student and course entities with following constraints: (i) Each teacher must take at least one course; (ii) A student can register one or more courses; (iii) A course may have teacher or not.
Answer.
What the examiner wants.
Definition of the E-R model (1 mark). An accurate Chen-notation E-R diagram enforcing three exact participation and cardinality constraints (4 marks): double line on teacher, double line on student, and single line on course.
Key idea.
"Must take at least one" or "can register one or more" means minimum participation is 1, which requires a double line (total participation). "May have teacher or not" means minimum participation is 0, which requires a single line (partial participation).
Step-by-step solution.
E-R Model:
The Entity-Relationship (E-R) model is a high-level conceptual data model. It views the real-world enterprise as a collection of basic objects called entities and relationships among these objects.
Constraints Mapping in E-R Diagram:
TEACHER in relationship Teaches, represented by a double line from TEACHER to Teaches (cardinality 1..*).STUDENT in relationship Registers, represented by a double line from STUDENT to Registers (cardinality 1..*, M:N relationship).COURSE in relationship Teaches, represented by a single line from COURSE to Teaches (cardinality 0..1 or 0..*).
Figure: E-R Diagram with Total and Partial Participation Constraints
Check.
Constraint verification:
Teaches: Single line present ✓ (allows 0 teachers for a course).Exam tip.
Highlight the double lines clearly on your answer sheet and add a short two-line note listing the constraints. Examiners check the line style first.
Sources.
Topic: T03.2 · Keys: super / candidate / primary / alternate / composite / foreign · Section A (Repeated question: Also asked in 2023 | Solved in T03)
Question. Explain the distinctions among the terms primary key, candidate key, and super key with proper example.
Answer.
What the examiner wants.
Precise definitions and clear distinctions among the four key types. The mark split is 1 mark per key type. The examiner expects minimality rules, nullability constraints, and an illustrative relational table.
Key idea.
Think of a super key as any attribute set that uniquely identifies a row. A candidate key is a minimal super key: removing any attribute ruins uniqueness. The primary key is the single candidate key chosen by the database designer. A composite key is any key consisting of two or more attributes.
Step-by-step solution.
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.
Check.
Minimality and closure verification:
name) and cannot be a candidate key.Exam tip.
Write down the subset formula Primary Key⊆Candidate Keys⊆Super Keys right above your example. This gives the examiner an instant visual proof of your grasp.
Sources.
Topic: T02.8 · EER: aggregation · Section A
Question. Define the concept of aggregation. Give two examples of where this concept is useful.
Answer.
What the examiner wants.
Definition of aggregation (1 mark). Two concrete real-world examples explaining why aggregation is useful to avoid redundancy (2 marks).
Key idea.
In standard E-R modeling, relationships cannot connect to other relationships. Aggregation solves this limitation. It wraps a relationship and its entities into a single abstract entity box, allowing other relationships to link to it directly.
Step-by-step solution.
Definition:
Aggregation is an abstraction in E-R modeling through which a relationship set is treated as a higher-level abstract entity set. This allows the relationship itself to participate in further relationships with other entity sets without duplicating attributes.
Figure: Aggregation Representation in E-R Diagram (Deck 05, Slide 59)
Two Examples Where Aggregation is Useful:
Student Project Evaluation:
The ternary relationship proj_guide associates student, instructor, and project. To record an evaluation for that specific guidance assignment, treating proj_guide as an aggregate entity avoids creating an overlapping ternary relationship. evaluation links directly to the aggregate proj_guide through the relationship eval_for.
Employee Project Monitoring:
Employees work on projects via the relationship Works_On. A manager needs to monitor that specific work assignment. By aggregating Works_On into an entity, the manager can participate in a relationship Monitors directly with the aggregate entity (Employee, Project).
Short version for 2020 Q.3(a) (2 marks):
Give the definition of aggregation and describe Example 1 (proj_guide with eval_for) in 2 lines.
Check.
Relational schema check for aggregation:
proj_guide: attributes (s_id, project_id, i_id).eval_for:
eval_for(s_id,project_id,i_id,evaluation_id)
proj_guide relationship table.Exam tip.
Define the concept clearly, mention the dashed/bounding rectangle around the relationship, and use the project guidance evaluation example from Deck 05 Slide 59.
Sources.
Topic: T02.6 · Reduction of E-R to relational tables · Section A
Question. Consider a database used to record the marks that students get in different examinations of different course offerings. (i) Construct an E-R diagram that models examinations as entities, and uses a ternary relationship for the above database; (ii) Draw a relational data model for the above corresponding E-R diagram.
Answer.
What the examiner wants.
Part (i): A Chen-notation E-R diagram showing a ternary relationship connecting Student, Course Offering, and Exam, with marks as a relationship attribute (2.5 marks).
Part (ii): The relational schemas derived from the diagram, with primary keys and foreign keys clearly designated (2.5 marks).
Key idea.
A ternary relationship associates three entities at once. When reduced to a relational schema, the ternary relationship becomes a table whose primary key is the composite union of the primary keys of all three participating entity sets.
Step-by-step solution.
(i) E-R Diagram with Ternary Relationship:
STUDENT, COURSE_OFFERING, EXAM.Scores connecting all three entity sets.marks (descriptive attribute placed on Scores).
Figure: Ternary Relationship Model for Student Exam Marks
(ii) Relational Data Model (Relational Schemas):
student(student_id, name, dept_name)
PK: student_id
course_offering(offering_id, semester, year)
PK: offering_id
exam(exam_id, exam_type, max_marks)
PK: exam_id
scores(student_id, offering_id, exam_id, marks)
PK: (student_id, offering_id, exam_id)
FK: student_id references student(student_id), offering_id references course_offering(offering_id), exam_id references exam(exam_id)
See also: Q.3(c) · 04 Marks (conversion of M:N relationships into relational tables).
Check.
Primary key verification:
exam_id varies.student_id varies.(student_id, offering_id, exam_id) are required to uniquely determine marks.Exam tip.
For Part (ii), format the relations clearly. Put primary key columns in bold and write a dedicated PK: and FK: line under each relation.
Sources.
Topic: T04.2 · Write RA queries on a given schema · Section A
Question.
Consider the following insurance database, where primary keys are underlined.person (<u>driver_id</u>, name, address)car (<u>license</u>, model, year)accident (<u>report_number</u>, date, location)owns (<u>driver_id</u>, license)participated (<u>driver_id</u>, car, <u>report_number</u>, damage_amount)
Write down the relational algebra statement for the following queries:
(i) Find the total number of people who owned cars that were involved in accidents in 1989.
(ii) Find the number of accidents in which the cars belonging to "John Smith" were involved.
(iii) Update the damage amounts for the car with license number "AABB2019" in the accident with report_number "AR201930" to $3000.
Answer.
What the examiner wants.
Three relational algebra statements worth 2 marks each. Tests multi-table joins, distinct counting with aggregation (γ), and relational tuple updating.
Key idea.
In part (i) and (ii), a person may own multiple cars or be involved in multiple accidents. Use count-distinct to count individual people and distinct accident reports without duplicate inflation. In part (iii), apply generalized projection on the matching record and union with all unaffected records.
Step-by-step solution.
Assumption: The calendar year is extracted from the date attribute using year(date)=1989.
(i) Total number of people who owned cars involved in accidents in 1989:
participated on report_number:owns matching participated.car = owns.license. This links each involved vehicle to its registered owner:(ii) Number of accidents involving cars belonging to "John Smith":
owns to find his registered vehicle licenses:participated by matching license numbers with participated.car:(iii) Update damage amounts for car "AABB2019" in accident "AR201930" to $3000:
damage_amount attribute with the literal value 3000:participated:participated as the union of both sets:Check.
Trace part (iii):
participated contains tuples ("D1", "AABB2019", "AR201930", 1500) and ("D2", "XY100", "AR201930", 500).("D1", "AABB2019", "AR201930", 1500).("D1", "AABB2019", "AR201930", 3000).("D2", "XY100", "AR201930", 500).Exam tip.
When counting people or entities involved across multiple events, always write count-distinct rather than plain count.
Sources.
[Lecture Deck 02 · Slides 16–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: T03.1 · Relation, tuple, attribute, domain; domain vs data type · Section A
Question. Differentiate between domain and data type.
Answer.
What the examiner wants.
A concise conceptual distinction between domain and data type. The mark split is 1 mark for definitions and 1 mark for comparison points with a clear example.
Key idea.
A data type describes how computer hardware stores data in memory (such as integer or text). A domain describes what data means in the real world (such as student age or course grades). Two attributes can share the same data type but belong to totally different domains.
Step-by-step solution.
A domain is the logical set of all valid values that an attribute can take. It defines real-world meaning and business constraints.
A data type is a physical storage format recognized by the computer hardware and DBMS. It defines memory layout and low-level bit representation.
| Comparison Point | Domain | Data Type |
|---|---|---|
| Concept Level | Conceptual and semantic level. It reflects business meaning. | Physical implementation level. It specifies storage layout. |
| Values Allowed | Strict set of valid real-world values (for example, letter grades {'A', 'B', 'C', 'F'}). | Broad machine-level value range (for example, CHAR(2) accepts any two characters). |
| Constraints | Carries logical rules and business checks (such as age >= 18). | Only restricts memory size and storage category (such as INT). |
| Equivalence | Two attributes with the same data type can have different domains. | Two attributes share the same data type if their storage format matches. |
Example: student_age and monthly_salary can both use the INT data type. But they belong to different domains. Adding an age to a salary makes no logical sense.
Check.
Quick self-test:
roll_number and bus_fare can both be INT, but comparing them is semantically meaningless.Exam tip.
Use a comparison table with four rows. Always add the age versus salary example to secure the full 2 marks.
Sources.
Topic: T02.3 · Mapping cardinality and participation constraints · Section A
Question. What is mapping cardinality? How a many to many relationship can be converted into table. Explain with example.
Answer.
What the examiner wants.
Definition of mapping cardinality (1 mark). Clear explanation of how an M:N relationship becomes a table (1.5 marks). A concrete worked example showing schemas, primary keys, and foreign keys (1.5 marks).
Key idea.
When entities have an M:N relationship, we cannot place the foreign key in either entity table without causing repeating groups or nulls. So we create a separate junction table. Its primary key combines the primary keys of both participating entities.
Step-by-step solution.
Mapping Cardinality:
Mapping cardinality (or cardinality ratio) expresses the number of entities to which another entity can be associated via a relationship set. For binary relationships, it must be 1:1, 1:N, N:1, or M:N.
Conversion of a Many-to-Many (M:N) Relationship into a Table:
Figure: Many-to-Many Relationship Model and Reduction to Relational Table
Example:
STUDENT with attributes student_id (PK), name.COURSE with attributes course_id (PK), title.Takes (M:N) with descriptive attribute grade.Relational Schemas:
student(student_id, name)
PK: student_id
course(course_id, title)
PK: course_id
takes(student_id, course_id, grade)
PK: (student_id, course_id)
FK: student_id references student(student_id), course_id references course(course_id)
Check.
Trace check:
S1 takes courses C1 and C2.S2 also takes course C1.takes stores:
(S1, C1, 'A')(S1, C2, 'B')(S2, C1, 'A')(student_id, course_id) uniquely identifies each enrollment.Exam tip.
State the general rule first (PK = PK(E1) ∪ PK(E2)). Then write out the exact schema with PK: and FK: lines.
Sources.
Topic: T08.1 · Why normalize: redundancy and insert/update/delete anomalies · Section A
Question. What problem may occur if databases are used without normalization? Discuss with proper example.
Answer.
What the examiner wants.
A structured answer listing data redundancy and the three classic modification anomalies (1.5 marks). Then, a concrete relational table example illustrating each problem clearly (2.5 marks).
Key idea.
When you lump multiple real-world entities into a single relation, you store the same fact repeatedly. This repetition wastes disk space. Worse, when you modify, insert, or delete data, the database either loses valid facts or ends up with conflicting values. Normalization fixes this by giving each independent entity its own table.
Step-by-step solution.
Using databases without normalization causes four major problems:
Consider an unnormalized table storing student enrollment and instructor data:
| Student_ID | Student_Name | Course | Instructor | Instructor_Phone |
|---|---|---|---|---|
| S01 | Riad | DBMS | Dr. Hasan | 01711... |
| S01 | Riad | AI | Dr. Abdullah | 01811... |
| S02 | Zoha | DBMS | Dr. Hasan | 01711... |
Student_ID is part of the primary key and cannot be NULL.Short version for CT-03 Q.02 (3 marks): State the four problems (data redundancy, update anomaly, insertion anomaly, deletion anomaly). Give a brief two-line explanation and one table row example showing an inconsistent update.
Check.
Quick self-test:
Student_ID is part of the primary key, and primary key attributes cannot be null.STUDENT, COURSE, and ENROLLMENT tables so course data exists independently of student enrollments.Exam tip.
Draw a simple 3-row table with 5 columns. Use it to demonstrate all three anomalies one by one. This takes less than two minutes and guarantees full marks.
Sources.
Topic: T09.1 · ACID properties · Section A
Question. Describe the ACID-properties of database system with appropriate diagram.
Answer.
What the examiner wants.
An explanation of the ACID properties accompanied by a clear illustrative diagram. The mark split is 2 marks for property descriptions and 2 marks for a diagram showing the transaction steps, state evolution, and ACID guarantees.
Key idea.
Use the standard $50 fund transfer transaction from account A to account B. Show how each ACID property applies to the intermediate and final database states.
Step-by-step solution.
To maintain database integrity against failures and concurrent updates, every transaction must satisfy four ACID properties:
Illustration with $50 Fund Transfer (T1):
Let account A have $1000 and account B have $2000. T1 moves $50 from A to B.
Figure: ACID properties in fund transfer transaction (Generated)
Mapping to the Diagram:
Check.
Quick self-test:
Exam tip.
Sketch the three boxes shown in the figure: Initial State (A=1000,B=2000), Intermediate State (A=950,B=2000, inconsistent), and Final State (A=950,B=2050). Add four callout arrows for A, C, I, and D.
Sources.
Topic: T08.6 · Define normalization (and its importance) & 1NF / 2NF / 3NF · Section A (Repeated question: Also asked in 2019 | Solved in T08)
Question. Explain the rules of 1NF and 2NF with a proper example.
Answer.
What the examiner wants.
Definition of normalization (1 mark), detailed discussion of 1NF rules with a clear example (1.5 marks), and 2NF rules with a clear example (1.5 marks).
Key idea.
1NF requires that every cell holds one single value (no lists). 2NF requires 1NF plus that every non-key attribute depends on the whole key, not just half of it.
Step-by-step solution.
Normalization is the process of decomposing a relation schema into smaller schemas to minimize data redundancy and prevent insertion, deletion, and update anomalies.
Rules:
Example:
Violating 1NF:
| Student_ID | Name | Phone |
|---|---|---|
| S01 | Fahim | 01711, 01822 |
| S02 | Noor | 01933 |
Converted to 1NF (atomic rows):
| Student_ID | Name | Phone |
|---|---|---|
| S01 | Fahim | 01711 |
| S01 | Fahim | 01822 |
| S02 | Noor | 01933 |
PK: (Student_ID, Phone)
Rules:
Example:
Consider relation ENROLL(StudentID, CourseID, StudentName, Grade):
(StudentID, CourseID)(StudentID, CourseID) -> Grade (Full dependency)StudentID -> StudentName (Partial dependency on proper subset StudentID)Converted to 2NF (decompose to remove partial dependency):
STUDENT(StudentID, StudentName) with PK StudentIDENROLLMENT(StudentID, CourseID, Grade) with PK (StudentID, CourseID)Short version for 2018 Q.4(c) (4 marks): State the rules for 1NF (atomicity, no multi-valued attributes) with the phone number example. State the rules for 2NF (in 1NF, no partial dependencies) with the student course example.
Check.
Quick self-test:
StudentName partially dependent in ENROLL?StudentID is already enough to determine StudentName; CourseID is completely unnecessary.Exam tip.
Keep the examples minimal: use a 2-row table for 1NF and a 4-attribute relation for 2NF.
Sources.
Topic: T09.5 · Concurrency problems · Section B
Question. If concurrency-control management is not implemented properly what problem may occur? Explain with example.
Answer.
What the examiner wants.
Identification and explanation of the data corruption anomalies that occur when concurrent transactions run without proper concurrency control. The examiner expects two-column chronological schedules showing exactly how values get corrupted. Mark split: 2 marks per problem explained with schedule.
Key idea.
When concurrent operations interleave without control, they violate isolation. The five classic concurrency anomalies are: Lost Update, Dirty Read (temporary update), Unrepeatable Read, Phantom Read, and Incorrect Summary.
Step-by-step solution.
If concurrency-control management is not implemented properly, uncoordinated interleaving violates transaction isolation. This causes five major anomalies:
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=500 | |
| t2 | A:=A−50 | T1 computes local A=450 | |
| t3 | write(A) | Database updated to A=450 | |
| t4 | write(A) | T2 performs blind write: A=25 | |
| t5 | commit | T1 commits | |
| t6 | commit | Final A=25 (T1's −50 update is lost!) |
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=100 | |
| t2 | A:=A+100 | T1 computes local A=200 | |
| t3 | write(A) | Database A=200 (uncommitted) | |
| t4 | read(A) | T2 reads dirty value A=200 | |
| t5 | A:=A−50 | T2 computes A=150 | |
| t6 | write(A) | Database A=150 | |
| t7 | commit | T2 commits with invalid data | |
| t8 | abort (Rollback) | T1 fails; log restores A=100 |
T2 based its computation on a temporary value that never officially existed, leaving the database inconsistent.
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=500 | |
| t2 | read(A) | T2 reads A=500 | |
| t3 | A:=A+100 | T2 computes local A=600 | |
| t4 | write(A) | Database A=600 | |
| t5 | commit | T2 commits | |
| t6 | read(A) | T1 reads A=600 (reads different value!) |
| Time | Transaction T1 | Transaction T2 | Note |
|---|---|---|---|
| t1 | read(A) | T1 reads data item A | |
| t2 | read(A) | T2 reads data item A | |
| t3 | delete(A) commit | T1 deletes data item A and commits | |
| t4 | read(A) | T2 attempts to read A again, but item does not exist |
| Time | Transaction T1 | Transaction T2 | Database / Summary State |
|---|---|---|---|
| t1 | read(A) A:=A−50 write(A) | T1 updates A to 950 on disk | |
| t2 | sum:=0 read(C) sum:=sum+C | T2 reads C=1000⟹sum=1000 | |
| t3 | read(A) sum:=sum+A | T2 reads updated A=950⟹sum=1950 | |
| t4 | read(B) sum:=sum+B | T2 reads old B=1000⟹sum=2950 | |
| t5 | avg:=sum/3 commit | T2 reports avg=2950/3≈983.33 | |
| t6 | read(B) B:=B+50 write(B) commit | T1 adds 50 to B (B=1050 on disk) |
Variant for 2024 Q.8(a) (3 marks):
List the five anomalies, then provide the full schedule tables for Lost Update and Dirty Read.
Short version for CT-04 Q.03 (4 marks):
Select Lost Update and Dirty Read with their definitions and schedule tables above.
Check.
Quick self-test:
Exam tip.
For 4-mark questions, pick Lost Update and Dirty Read as your primary two examples. They are the easiest to draw and the most convincing to examiners.
Sources.
Topic: T11.4 · Deadlock: conditions, prevention vs detection, wait-for graph, victim selection · Section B
Question. What do you know about deadlock in transaction management? Under what conditions it is less expensive to avoid deadlock than to allow deadlocks to occur and then to detect them?
Answer.
What the examiner wants.
This question comes from Textbook Exercise 18.20. The examiner looks for the concept of deadlock in transactions (1 mark), followed by a clear trade-off analysis explaining when prevention or avoidance is cheaper than detection and recovery (3 marks).
Key idea.
Deadlock detection lets transactions run freely until they lock up, then detects cycles and aborts victims. Avoidance or prevention restricts lock requests so deadlocks never happen. If transactions clash often, detecting deadlocks leads to constant, expensive rollbacks. In that case, prevention is cheaper. But if transactions rarely conflict, detection is cheaper because prevention imposes unnecessary rules and false aborts.
Step-by-step solution.
1. Deadlock in Transaction Management:
A deadlock is a state where concurrent transactions block one another permanently. Each transaction holds a lock that another transaction needs and waits for a lock that another holds. A circular wait forms in the system wait-for graph. The transactions can make no further progress. The database system must break the deadlock by picking a victim transaction and rolling it back.
2. When Avoidance / Prevention is Less Expensive Than Detection:
Deadlock avoidance or prevention is less expensive than detection and recovery under these conditions:
3. When Detection is Less Expensive:
Deadlock detection is cheaper when deadlocks are rare. This occurs when transactions are short, concurrency is moderate, and data access sets are largely disjoint. Under these conditions, transactions rarely block. Running detection only periodically allows maximum concurrency without the strict locking rules or false-positive aborts of prevention protocols.
Check.
Trade-off summary:
Exam tip.
Divide the second part of your answer into clear conditions: high contention vs low contention, and long vs short transactions.
Sources.
Topic: T12.1 · Failure classification, precautions, recovery methods · Section B (Special 2+2 Mark Question: Failures in DBMS & RAID Recovery)
Question. Discuss each type of failure that can happen in DBMS. How does RAID model help to recover a system?
Answer.
What the examiner wants.
A concise summary of the three main failure types in a DBMS, sized appropriately for a 2-mark portion of a split question.
Key idea.
Group failures into transaction-level errors, system-level memory wipes, and physical drive crashes.
Step-by-step solution.
A DBMS is subject to three primary failure types:
Check.
Quick self-test:
Exam tip.
Keep each failure type to one concise sentence. This leaves enough time to answer the RAID part.
Sources.
What the examiner wants.
An explanation of how RAID architectures recover from disk and sector failures without taking the database offline.
Key idea.
RAID stores redundant information (duplicate mirror drives or parity blocks) across multiple physical drives. If one drive fails, data is served from the mirror or calculated using XOR logic.
Step-by-step solution.
The RAID (Redundant Array of Independent Disks) model protects the database system from disk and media failures in three ways:
Check.
Quick self-test:
Exam tip.
Focus directly on disk failure tolerance: mirroring failover, parity XOR math, and hot-spare background rebuilds.
Sources.
Topic: T09.4 · Concurrent execution advantages and schedules · Section B
Question. Define transaction and schedule. What is the difference between serial schedule and serializable schedule?
Answer.
What the examiner wants.
Definitions of transaction (1 mark) and schedule (1 mark), followed by a structured comparison contrasting serial schedules with serializable schedules (2 marks).
Key idea.
A serial schedule executes transactions sequentially without interleaving. A serializable schedule interleaves operations from different transactions for performance, but is mathematically equivalent in its final effect to some serial schedule.
Step-by-step solution.
Definitions:
Difference Between Serial Schedule and Serializable Schedule:
| Feature | Serial Schedule | Serializable Schedule |
|---|---|---|
| Instruction Interleaving | No interleaving. Transactions run strictly one after another; each finishes before the next begins. | Instructions of multiple transactions are interleaved concurrently. |
| System Concurrency | Zero concurrency. Hardware sits idle during disk I/O waits. | High concurrency. CPU and disk operate in parallel across transactions. |
| Throughput & Latency | Low throughput. Short transactions suffer long queue delays. | High throughput. Short transactions complete with low average response time. |
| Correctness | Always correct and consistent by default. | Correct only if it produces the same final state as some serial execution. |
| Verification | No verification needed. | Requires testing (e.g., precedence graph cycle check for conflict serializability). |
Check.
Quick self-test:
Exam tip.
Use a comparison table for the second half of the question. Tabular answers make marking fast and guarantee full credit.
Sources.
Topic: T11.6 · Timestamp ordering: R-TS/W-TS rules, trace a schedule; rolled-back transaction gets a NEW timestamp · Section B
Question. When a transaction is rolled back under timestamp ordering and it is assigned a new timestamp? Why can it not simply keep its old timestamp?
Answer.
What the examiner wants.
This question comes from Textbook Exercise 18.26. The examiner wants:
Key idea.
Timestamp ordering makes older transactions execute before younger ones. If an older transaction arrives late and tries to read or write an item that a younger transaction already altered, the order is broken. So the older transaction is rolled back. When it restarts, it must get a new, higher timestamp. If it kept its old timestamp, the exact same conflict would happen all over again, causing starvation.
Step-by-step solution.
1. When a Transaction is Rolled Back Under Timestamp Ordering:
Under the Timestamp Ordering (TSO) protocol, a transaction Ti with timestamp TS(Ti) is rolled back when it attempts an out-of-order operation:
read(Q) Operation:write(Q) Operation:
2. Assigning a New Timestamp:
When Ti is rolled back, the system aborts it and cleans up its partial changes. When Ti is restarted, the system assigns it a new, larger timestamp based on the current system clock or logical counter.
3. Why It Cannot Keep Its Old Timestamp:
Short version for 2024 Q.8(b) (3 marks): Give the read and write rollback conditions concisely. Then explain in 2 points why the old timestamp causes repeated aborts and starvation.
Check.
Logic check:
Exam tip.
Be very clear on the distinction: deadlock prevention (wait-die) keeps old timestamps; timestamp ordering (TSO) assigns new timestamps. Examiners check for this exact distinction.
Sources.
Topic: T10.3 · Precedence-graph test → cycle → serial order(s) · Section B
Question.
Consider the following schedule.
| T1 | T2 |
|---|---|
| read(A); | |
| A:=A+10; | |
| read(A); | |
| A:=A-100; | |
| write(A); | |
| read(B); | |
| write(A); | |
| read(B); | |
| B:=B-10; | |
| write(B) | |
| B:=B+100; | |
| write(B); |
Answer.
What the examiner wants. Chronological extraction of conflicting read/write instructions (1 mark), edge listing for the precedence graph (1.5 marks), graph diagram and cycle detection (1 mark), and the final verdict (0.5 marks).
Key idea. A schedule of transactions is conflict serializable if and only if its precedence graph is acyclic. We build the graph by checking pairs of conflicting instructions on the same data item. If T1 accesses an item before T2 performs a conflicting operation, we draw an edge T1→T2. If another pair requires T2→T1, a cycle forms, proving the schedule cannot be serialized.
Step-by-step solution.
We ignore local arithmetic (A:=A+10, etc.) and focus on the database read and write instructions in order:
We compare instructions between different transactions on the same data item where at least one is a write:

The precedence graph consists of vertices {T1,T2} and directed edges:
This produces a directed cycle:
T1⟷T2Result: The precedence graph contains a cycle. Therefore, the schedule is NOT conflict serializable.
Check.
Exam tip. Always check both data items (A and B). Even if you spot the cycle on item A, listing the conflicts on item B guarantees full marks.
Sources.
Topic: T05.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · Section B
Question.
Write down the SQL queries for following operations.
(i) Create table for student (roll, Name, Dept)
(ii) Insert one example entry for student table
(iii) Modify the student table to student(roll, Name, dept, session)
(iv) Show the roll and name of the students of ECE department only.
Answer.
What the examiner wants.
Four fundamental SQL operations (1 mark each):
CREATE TABLE with underlined attributes as primary key.INSERT INTO syntax.ALTER TABLE to append a new column.SELECT with projection and equality selection predicate.Key idea.
Relational tables start with a schema definition (CREATE), receive tuples (INSERT), adapt to new requirements via schema modification (ALTER), and answer inquiries through projection and selection (SELECT).
Step-by-step solution.
(i) Create student table:
CREATE TABLE student (
roll INT,
name VARCHAR(50),
dept VARCHAR(20),
PRIMARY KEY (roll, dept)
);
(ii) Insert one example entry:
INSERT INTO student (roll, name, dept)
VALUES (1810001, 'Rahim', 'ECE');
(iii) Modify student table to add session:
ALTER TABLE student
ADD session VARCHAR(10);
(iv) Show roll and name of students from ECE:
SELECT roll, name
FROM student
WHERE dept = 'ECE';
Variant for 2024 Q.4(b) (4 marks): The identical queries answer parts (i) through (iv).
Check.
Schema progression:
NULL for session.dept = 'ECE' and projects only roll and name.Exam tip.
For 1-mark sub-questions, write standard SQL without superfluous clauses.
Sources.
Deck 03 · Slides 7–11, 13, 17, Textbook Ch. 3 §3.2, §3.3.
Topic: T05.5 · Aggregation queries: GROUP BY + HAVING, CGPA, extremes without LIMIT · Section B
Question.
Consider the following data tables:Product (p_id, p_name, quantity, unit_price)Customer (c_id, c_name, contact)Sales (c_id, p_id, quantity)
Write down SQL expressions for following queries.
(i) Show the information of those customers who have bought more than five different products.
(ii) Show the information of those products that were sold more than ten pieces.
(iii) Show the information of the product with maximum sale (maximum sold amount of money or bought by the maximum customer).
(iv) Show the product id and corresponding remaining quantity of that product.
Answer.
What the examiner wants.
Four complex business queries (2 marks each):
HAVING COUNT(DISTINCT ...) > 5.HAVING SUM(quantity) > 10.LEFT JOIN and COALESCE to prevent unsold products from disappearing.Key idea.
HAVING filters aggregated groups after GROUP BY, whereas WHERE filters individual rows prior to grouping. For inventory tracking, unsold products have no matching rows in Sales. An inner join drops them, so an outer join (LEFT JOIN) with COALESCE(SUM(s.quantity), 0) is required to report full starting stock for unsold items.
Step-by-step solution.
(i) Customers who bought more than five different products:
SELECT c.c_id, c.c_name, c.contact
FROM Customer c
JOIN Sales s ON c.c_id = s.c_id
GROUP BY c.c_id, c.c_name, c.contact
HAVING COUNT(DISTINCT s.p_id) > 5;
(ii) Products sold more than ten pieces:
SELECT p.p_id, p.p_name, p.quantity, p.unit_price
FROM Product p
JOIN Sales s ON p.p_id = s.p_id
GROUP BY p.p_id, p.p_name, p.quantity, p.unit_price
HAVING SUM(s.quantity) > 10;
(iii) Product with maximum sale:
Primary interpretation: Maximum sold amount of money (∑(quantity×unit_price)):
SELECT p.p_id, p.p_name, p.quantity, p.unit_price,
SUM(s.quantity * p.unit_price) AS total_sales_value
FROM Product p
JOIN Sales s ON p.p_id = s.p_id
GROUP BY p.p_id, p.p_name, p.quantity, p.unit_price
ORDER BY total_sales_value DESC
LIMIT 1;
(Alternative subquery without LIMIT to return all tied products on top revenue):
SELECT p.p_id, p.p_name, p.quantity, p.unit_price
FROM Product p
JOIN Sales s ON p.p_id = s.p_id
GROUP BY p.p_id, p.p_name, p.quantity, p.unit_price
HAVING SUM(s.quantity * p.unit_price) = (
SELECT MAX(prod_rev)
FROM (
SELECT SUM(s2.quantity * p2.unit_price) AS prod_rev
FROM Sales s2
JOIN Product p2 ON s2.p_id = p2.p_id
GROUP BY s2.p_id
) AS sub
);
Alternative interpretation: Bought by the maximum number of distinct customers:
SELECT p.p_id, p.p_name, p.quantity, p.unit_price,
COUNT(DISTINCT s.c_id) AS customer_count
FROM Product p
JOIN Sales s ON p.p_id = s.p_id
GROUP BY p.p_id, p.p_name, p.quantity, p.unit_price
ORDER BY customer_count DESC
LIMIT 1;
(iv) Product ID and corresponding remaining quantity:
SELECT p.p_id,
p.quantity - COALESCE(SUM(s.quantity), 0) AS remaining_quantity
FROM Product p
LEFT JOIN Sales s ON p.p_id = s.p_id
GROUP BY p.p_id, p.quantity;
Check.
Trace of part (iv) inventory calculation:
quantity = 100. Sold 20 in Sales. SUM = 20. Remaining = 100 - 20 = 80.quantity = 50. Never sold. Sales row is NULL. COALESCE(NULL, 0) = 0. Remaining = 50 - 0 = 50.LEFT JOIN preserves Product B.Exam tip.
Whenever an inventory problem asks for remaining quantity, always write a LEFT JOIN with COALESCE to account for unsold inventory items.
Sources.
Deck 03 · Slides 32–34, 48–51, Deck 04 · Slides 5–7, Textbook Ch. 3 §3.7.
Topic: T07.1 · What a trigger is, its purposes, and its syntax · Section B
Question. What is triggering? What are the purposes of using trigger? Write the syntax for creating trigger?
Answer.
What the examiner wants.
A complete three-part answer: the definition of trigger and triggering (1.5 marks), four distinct practical purposes (1.5 marks), and the exact syntax for creating a trigger (2 marks).
Key idea.
A trigger is an automated stored routine. It wakes up when a table event occurs, tests an optional condition, and runs an action. Think of a smoke detector. When smoke appears (event), it checks whether smoke density is high (condition), and rings an alarm (action). This structure is the ECA model.
Step-by-step solution.
A trigger is a stored SQL block. The DBMS executes it automatically when a modification occurs on a table or view.
The automatic detection of the event and execution of the trigger action is called triggering.
Triggers follow the ECA (Event-Condition-Action) model:
INSERT, UPDATE, or DELETE) that activates the trigger.CHECK, FOREIGN KEY) cannot express.General Template:
DELIMITER //
CREATE TRIGGER trigger_name
{BEFORE | AFTER} {INSERT | UPDATE | DELETE}
ON table_name
FOR EACH ROW
BEGIN
-- Trigger body statements
-- Access row values via OLD.column_name and NEW.column_name
-- Terminate and rollback on error using SIGNAL
END //
DELIMITER ;
BEFORE | AFTER: Specifies whether the action executes before modifying table data or after the modification completes.INSERT | UPDATE | DELETE: Identifies the DML event that activates the trigger.ON table_name: Specifies the target table.FOR EACH ROW: Defines a row-level trigger that runs once for each affected row.OLD and NEW: Transition qualifiers that refer to column values before and after the change.Example (Enforcing non-negative stock before insert):
DELIMITER //
CREATE TRIGGER trg_check_product_stock
BEFORE INSERT ON Products
FOR EACH ROW
BEGIN
IF NEW.stock < 0 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Error: Stock level cannot be negative';
END IF;
END //
DELIMITER ;
Variant for 2020 Q.8(a) (4 marks): The same definition, purposes, syntax template, and example answer the question directly.
Check.
Quick self-test:
FOR EACH ROW needed?UPDATE event?OLD (values before the change) and NEW (values after the change).INSERT trigger access OLD.column_name?OLD is undefined.Exam tip.
Divide your answer into three clear numbered headings: Definition and ECA model, Purposes, and Syntax. This structure lets the examiner assign full marks quickly.
Sources.
Topic: T12.2 · Role of the recovery manager · Section B
Question. Suppose that there is a database system that never failed, is a recovery manager required for this system? Justify your answer.
Answer.
What the examiner wants.
An unambiguous affirmative answer ("Yes"), followed by a rigorous technical justification showing that transaction rollbacks occur even when the underlying hardware and operating system never crash.
Key idea.
System crashes and disk failures are not the only reasons transactions fail. Individual transactions frequently abort due to logic errors, input validation errors, deadlock resolution, or explicit user cancellations. Atomicity requires that these aborted transactions be undone.
Step-by-step solution.
Yes, a recovery manager is still required.
Even in a hypothetical system where the hardware and operating system never crash, a recovery manager is essential for the following reasons:
ROLLBACK when funds are insufficient).Check.
Quick self-test:
Exam tip.
Start with a direct "Yes" in bold, then list the causes of transaction failure (logical errors, user rollbacks, deadlocks) and link them directly to atomicity.
Sources.
Topic: T12.4 · RAID levels, comparison, and recovery role · Section B
Question. Describe the different RAID levels.
Answer.
What the examiner wants.
A structured description of the primary RAID levels (0, 1, 5, 6) including striping, redundancy mechanisms, and fault tolerance, accompanied by the standard textbook diagram and short notes on legacy levels.
Key idea.
RAID levels represent different design trade-offs between I/O speed, storage overhead, and fault tolerance.
Step-by-step solution.
Figure 12.4: RAID levels (Textbook Ch. 12, Figure 12.4)
RAID organizes multiple physical disks to provide performance and fault tolerance. The primary levels are:
Summary of Other Levels:
Check.
Quick self-test:
Exam tip.
For each level, clearly state: (1) striping unit, (2) redundancy type, and (3) number of disk failures tolerated.
Sources.
← Prev: 2017 | Exam-Style Layer | Original Question Paper | Next: 2019 →