50.4 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 | exam-style |
← Prev: 2017 | Explanation 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.
A database stores information efficiently by removing the major storage and access bottlenecks of traditional file systems:
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.
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.
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.
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
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.
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: T02.8 · EER: aggregation · Section A
Question. Define the concept of aggregation. Give two examples of where this concept is useful.
Answer.
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.
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.
(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).
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.
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:
Join accident records from 1989 with participated cars and ownership data, then count distinct owners:
T1←σyear(date)=1989(accident)⋈participated T2←T1⋈participated.car=owns.licenseowns γcount-distinct(owns.driver_id)(T2)(ii) Number of accidents involving cars belonging to "John Smith":
Find cars owned by John Smith, join with accident participation records, and count distinct accidents:
Tjohn_cars←σname="John Smith"(person)⋈owns Taccidents←Tjohn_cars⋈owns.license=participated.carparticipated γcount-distinct(report_number)(Taccidents)(iii) Update damage amounts for car "AABB2019" in accident "AR201930" to $3000:
Define the predicate for the specific accident record and update the damage_amount attribute:
Topic: T03.1 · Relation, tuple, attribute, domain; domain vs data type · Section A
Question. Differentiate between domain and data type.
Answer.
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.
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.
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)
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.
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.
Topic: T09.1 · ACID properties · Section A
Question. Describe the ACID-properties of database system with appropriate diagram.
Answer.
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:
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.
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.
Topic: T09.5 · Concurrency problems · Section B
Question. If concurrency-control management is not implemented properly what problem may occur? Explain with example.
Answer.
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.
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.
Deadlock in Transaction Management:
A deadlock is an execution state where a set of transactions {T1,T2,…,Tn} cannot proceed because each transaction waits for a lock held by another transaction in the set. A circular wait forms in the wait-for graph. The DBMS must intervene, select a victim transaction, and roll it back to break the cycle.
When Avoidance / Prevention is Less Expensive Than Detection:
Deadlock avoidance or prevention is less expensive than detection and recovery under the following conditions:
When Detection is Less Expensive:
When deadlocks are rare (short transactions, low concurrency, mostly disjoint data items), detection is cheaper. Prevention mechanisms reduce concurrency or cause false-positive aborts. Detection allows transactions to run freely and resolves only the rare deadlock that occurs.
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.
A DBMS is subject to three primary failure types:
The RAID (Redundant Array of Independent Disks) model protects the database system from disk and media failures in three ways:
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.
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). |
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.
When a Transaction is Rolled Back Under Timestamp Ordering:
Under the Timestamp Ordering (TSO) protocol, a transaction Ti is rolled back whenever it attempts an operation that conflicts with a younger transaction:
Assigning a New Timestamp:
When Ti is rolled back, the system aborts it and restarts it. Upon restarting, the system assigns Ti a new, larger timestamp using the current system clock or logical counter.
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.
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.
We extract the sequence of database operations in chronological order:
A conflict occurs when two instructions from different transactions access the same item and at least one is a write:

The graph contains directed edges T1→T2 and T2→T1. This creates a cycle:
T1⟷T2Result: Because the precedence graph contains a cycle, the schedule is NOT conflict serializable.
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.
(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).
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.
(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;
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.
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.
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.
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).Topic: T12.4 · RAID levels, comparison, and recovery role · Section B
Question. Describe the different RAID levels.
Answer.
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:
← Prev: 2017 | Explanation Layer | Original Question Paper | Next: 2019 →