84.3 KB · commit 40bb182
| year | 2024 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2024 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 60 |
| time | 3 Hours |
| layer | explanation |
← Prev: 2023 | Exam-Style Layer | Original Question Paper | Next: ClassTestQuestions →
Topic: T01.2 · File system vs DBMS · Section A · 1
Question. A courier tracking company maintains large files for daily parcel updates. The data grows rapidly and requires fast retrieval. Choose between a file based system and a DBMS and justify the decision.
Answer.
What the examiner wants.
An explicit recommendation (DBMS) and a justification directly using the scenario's facts: rapid data growth, fast retrieval, concurrent tracking updates, and data reliability. Mark split: 1 mark for the decision, 3 marks for linking scenario facts to technical justifications.
Key idea.
A courier tracking service handles thousands of package updates and queries every hour. A file system would degrade rapidly because searching through growing flat files requires linear scans, and concurrent writes cause file corruption or severe locking delays. A DBMS provides indexing, concurrency control, and scalability.
Step-by-step solution.
Decision: Choose a DBMS (Database Management System).
Justification:
parcel_id). This delivers lookup results in milliseconds instead of scanning large files line by line.Check.
Scenario link verification:
Exam tip.
Start with a bold decision line. Then quote the scenario requirements directly in your justification bullet points.
Sources.
Topic: T02.5 · Design a full E-R diagram for a scenario · Section A · 3 (Repeated question: Also asked in 2017 | Solved in T02)
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: T05.5 · Aggregation queries: GROUP BY + HAVING, CGPA, extremes without LIMIT · Section A · 2
Question.
STUDENT (SID, Name, Age, Major)
COURSE (CID, Title, Credits)
ENROLLMENT (SID, CID, Grade)
Using the above schema, write a SQL query to find the average grade for each course.
Answer.
What the examiner wants.
A clean SQL aggregation query using AVG(Grade) grouped by course identifier (CID).
Key idea.
The ENROLLMENT table contains both the course identifier (CID) and the student's grade (Grade). Grouping by CID allows AVG() to compute the arithmetic mean per course without requiring a join to other relations.
Step-by-step solution.
SELECT CID,
AVG(Grade) AS avg_grade
FROM ENROLLMENT
GROUP BY CID;
(If course title is also retrieved by joining COURSE):
SELECT c.CID, c.Title,
AVG(e.Grade) AS avg_grade
FROM COURSE c
JOIN ENROLLMENT e ON c.CID = e.CID
GROUP BY c.CID, c.Title;
Check.
Trace:
AVG(Grade) yields 33.5+3.75+4.0=3.75.(CID, avg_grade).Exam tip.
Provide the direct single-table query first; append the joined version with Title as an alternative if descriptive course names are desired.
Sources.
Deck 03 · Slides 30–32, Textbook Ch. 3 §3.7.
Topic: T07.2 · Triggers for security before and after a breach · Section A · 2 (Repeated question: Also asked in 2017 | Solved in T07)
Question. Discuss how trigger can contribute to the security of database before and after a security breach. Explain with example.
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: T04.2 · Write RA queries on a given schema · Section A · 1
Question.
EMPLOYEE (EID, Name, Department, Salary)
PROJECT (PID, Name, Budget)
WORKS_ON (EID, PID, Hours)
Suppose a company wants to find employees working on multiple projects. Write the relational algebra expression for it.
Answer.
What the examiner wants.
A relational algebra expression worth 4 marks to find employees assigned to more than one project. The examiner expects either aggregation with grouping and threshold filtering (γ), or classical pure relational algebra using a self-join.
Key idea.
Count the distinct projects per employee. An employee works on multiple projects if their project count exceeds 1. Alternatively, perform a self-join on WORKS_ON where the employee ID is the same but the project IDs differ.
Step-by-step solution.
Method 1: Aggregation Operation (Standard Solution)
WORKS_ON by EID and count the project IDs:EMPLOYEE on EID to retrieve employee details and project the name:Method 2: Pure Relational Algebra via Self-Join (Classical Alternative)
WORKS_ON with a renamed copy of itself:EID but different PID:EMPLOYEE to retrieve employee names:Check.
Sample data for WORKS_ON:
(E1, P1, 10), (E1, P2, 15), (E2, P1, 20).
Method 1: E1 has count 2 (>1). E2 has count 1 (>1). Join with EMPLOYEE returns E1.
Method 2: Pairing (E1, P1) with (E1, P2) matches E1=E1 and P1=P2. E1 is selected. E2 has only one project, so no pair with different PID exists.
Exam tip.
Method 1 using γ is concise and preferred. Mentioning the self-join method in one sentence shows complete mastery of both modern extended algebra and classical pure algebra.
Sources.
[Lecture Deck 02 · Slides 27–29](../LectureSlides/02_Relational_Model.md)
[Textbook Ch. 16 §16.1](../Textbook/Chapter_16_Query_Optimization/Chapter%2016%20-%20Query%20Optimization.md)
Topic: T09.2 · Consistency property alone, with example · Section A · 1 (Repeated question: Also asked in 2019 | Solved in T09)
Question. Explain the consistency property of a database system with a proper example.
Answer.
What the examiner wants.
A dedicated discussion of the consistency property. The examiner looks for the distinction between explicit constraints and implicit application invariants, along with a concrete numerical example showing temporary internal inconsistency versus final restored consistency. Mark split: 1 mark for definition/types, 2 marks for the example.
Key idea.
Consistency means preserving truth and valid business invariants. While a transaction is running, the database can be temporarily inconsistent internally. But once the transaction finishes, consistency must be fully restored.
Step-by-step solution.
Definition:
The consistency property requires that executing a transaction in isolation preserves the consistency of the database. If the database starts in a valid state that satisfies all integrity rules, it must end in a valid state after the transaction completes.
Categories of Consistency Constraints:
CHECK constraints (such as balance >= 0).Example (Bank Transfer):
Let account A have $1000 and account B have $2000. The consistency invariant requires total funds to remain constant:
Transaction T1 transfers $50 from A to B:
Check.
Quick self-test:
Exam tip.
Explicitly state that temporary inconsistency during execution is normal and necessary. The requirement is that consistency is restored when the transaction finishes.
Sources.
Topic: T08.8 · Normalize an unnormalized table → 1NF → 2NF → 3NF · Section A · 2
Question. A library database stores information about Books, Authors, Publishers and Borrowers. Create a table that contains some data redundancy and partial dependencies. Also, show the procedure to normalize the table.
Answer.
What the examiner wants.
Designing an unnormalized library table that clearly exhibits data redundancy and partial dependencies (2 marks), followed by a clear step-by-step normalization procedure decomposing into 2NF and 3NF relations (2 marks).
Key idea.
Create a table with a composite primary key like (Book_ID, Borrower_ID). Store book details (title, publisher) and borrower details (borrower name) alongside the loan date. Because book details depend only on Book_ID and borrower name depends only on Borrower_ID, the table has clear partial dependencies and redundancy.
Step-by-step solution.
Consider a single table LIBRARY_LOAN designed to store all lending records:
| Book_ID | Borrower_ID | Title | Author_ID | Author_Name | Publisher_Name | Borrower_Name | Borrow_Date |
|---|---|---|---|---|---|---|---|
| B101 | U01 | DBMS Concepts | A1 | Silberschatz | McGraw-Hill | Akib | 2024-01-10 |
| B101 | U02 | DBMS Concepts | A1 | Silberschatz | McGraw-Hill | Shuvo | 2024-02-15 |
| B202 | U01 | Operating Systems | A1 | Silberschatz | Wiley | Akib | 2024-03-01 |
Primary Key: (Book_ID, Borrower_ID)
Functional Dependencies:
Book_ID -> Title, Author_ID, Publisher_Name (partial dependency on subset Book_ID)Author_ID -> Author_Name (transitive dependency)Borrower_ID -> Borrower_Name (partial dependency on subset Borrower_ID)(Book_ID, Borrower_ID) -> Borrow_Date (full dependency)Data Redundancy:
Decompose LIBRARY_LOAN so non-prime attributes depend only on the full primary key:
BOOK_INFO(Book_ID, Title, Author_ID, Author_Name, Publisher_Name) with PK Book_IDBORROWER(Borrower_ID, Borrower_Name) with PK Borrower_IDLOAN(Book_ID, Borrower_ID, Borrow_Date) with PK (Book_ID, Borrower_ID)This eliminates partial dependencies and achieves 2NF.
In BOOK_INFO, the dependency Author_ID -> Author_Name is transitive because Author_ID is a non-prime attribute determining Author_Name.
We decompose BOOK_INFO into:
BOOK(Book_ID, Title, Author_ID, Publisher_Name) with PK Book_ID and FK Author_IDAUTHOR(Author_ID, Author_Name) with PK Author_IDBook_ID, Title, Author_ID, Publisher_Name)Book_ID | FK: Author_ID references AUTHOR(Author_ID)Author_ID, Author_Name)Author_IDBorrower_ID, Borrower_Name)Borrower_IDBook_ID, Borrower_ID, Borrow_Date)(Book_ID, Borrower_ID) | FKs: Book_ID references BOOK, Borrower_ID references BORROWERCheck.
Self-test on entities:
Publisher_Name is recorded with each Book.LOAN contains only the composite key (Book_ID, Borrower_ID) and its fully dependent attribute Borrow_Date.Exam tip.
Keep your invented table small: 3 rows and 8 columns are enough to showcase both partial and transitive dependencies clearly.
Sources.
Topic: T12.1 · Failure classification, precautions, recovery methods · Section A · 1 (Repeated question: Also asked in 2019 | Solved in T12)
Question. Discuss the ways of DBMS can be failed. Also, mention the precautions should be taken considering the failure of DBMS and point out the recovery methods.
Answer.
What the examiner wants.
A three-part answer covering failure modes (2 marks), runtime precautions (1.5 marks), and recovery methods (1.5 marks).
Key idea.
A database handles failures in two distinct stages. First, it takes proactive precautions during normal runtime (logging, RAID, battery backups). Second, it executes reactive recovery algorithms (undo/redo, checkpoints) after a failure occurs.
Step-by-step solution.
A DBMS can fail in three primary ways:
Short version for 2024 Q.3(b) (CO1, 4 marks): Provide the same three sections in concise bullet points to fit the 4-mark time limit.
Check.
Quick self-test:
Exam tip.
Use three distinct headings matching the prompt: Failures, Precautions, and Recovery Methods.
Sources.
Topic: T06.1 · Types of joins · Section A · 1
Question. Differentiate between inner joining and outer joining.
Answer.
What the examiner wants.
A concise, structured comparison highlighting the differences between inner joins and outer joins for 2 marks. Examiners look for tuple retention, handling of missing values, and query syntax.
Key idea.
An inner join is strict: it only outputs rows where both tables satisfy the join condition. An outer join is inclusive: it preserves non-matching rows from one or both tables by padding empty columns with NULL.
Step-by-step solution.
| Feature | Inner Join | Outer Join |
|---|---|---|
| Tuple Retention | Keeps only matching tuples from both relations. Drops non-matching rows. | Preserves matching rows plus unmatched rows from one or both relations. |
| Missing Values | Never produces NULL values to represent missing relationship data. | Pads missing attributes of unmatched tuples with NULL. |
| Information Loss | Loses dangling records that fail the join predicate. | Prevents information loss by keeping all records from preserved relations. |
| Forms / Syntax | Theta join, equijoin, and natural join (INNER JOIN, JOIN). | Left outer, right outer, and full outer join (LEFT JOIN, RIGHT JOIN, FULL JOIN). |
Check.
Quick self-test:
NULL for attributes of table B.Exam tip.
For a 2-mark distinction question, write a 3 to 4 row comparison table. It takes under two minutes and secures full marks.
Sources.
Topic: T06.2 · Join outcome tables · Section A · 2
Question.
Consider the following tables:
Courses
| Code | Series | t_code |
|---|---|---|
| E_2215 | 2020 | T1 |
| E_4127 | 2021 | T2 |
| E_1203 | 2022 | T3 |
| E_2219 | 2021 | T3 |
| t_code | Designation |
|---|---|
| T1 | Head |
| T2 | AP |
| T3 | AP |
| T4 | Lecturer |
Answer.
What the examiner wants.
Step-by-step derivation of each join outcome with schema names, row counts, explanation of matching tuples, and resulting Markdown tables (1.5 marks per operation).
Key idea.
The common attribute is t_code. Here, teacher T3 teaches two courses (E_1203 and E_2219). Teacher T2 and T1 each teach one course. Teacher T4 has no course. All rows in Courses match a teacher, so left join produces 4 rows. Right and full outer joins append T4 with NULL values to produce 5 rows.
Step-by-step solution.
The common attribute between Courses and Teacher is t_code.
Matches tuples with equal t_code values and retains one copy of t_code.
Relational algebra:
Courses⋈TeacherMySQL query:
SELECT Code, Series, t_code, Designation
FROM Courses
NATURAL JOIN Teacher;
Outcome Table (4 rows):
| Code | Series | t_code | Designation |
|---|---|---|---|
| E_2215 | 2020 | T1 | Head |
| E_4127 | 2021 | T2 | AP |
| E_1203 | 2022 | T3 | AP |
| E_2219 | 2021 | T3 | AP |
Explanation: T1, T2, and T3 have matches in Teacher. T3 matches twice because two courses share T3. Teacher T4 has no course match and is omitted.
Preserves all tuples from the left relation (Courses). Unmatched right-side fields are set to NULL.
Relational algebra:
Courses⟕TeacherMySQL query:
SELECT Courses.Code, Courses.Series, Courses.t_code, Teacher.Designation
FROM Courses
LEFT JOIN Teacher ON Courses.t_code = Teacher.t_code;
Outcome Table (4 rows):
| Code | Series | t_code | Designation |
|---|---|---|---|
| E_2215 | 2020 | T1 | Head |
| E_4127 | 2021 | T2 | AP |
| E_1203 | 2022 | T3 | AP |
| E_2219 | 2021 | T3 | AP |
Explanation: Every course row has an assigned t_code present in Teacher. No NULL padding is needed. The outcome is identical to the Natural Join.
Preserves all tuples from the right relation (Teacher). Unmatched left-side fields are filled with NULL.
Relational algebra:
Courses⟖TeacherMySQL query:
SELECT Courses.Code, Courses.Series, Teacher.t_code, Teacher.Designation
FROM Courses
RIGHT JOIN Teacher ON Courses.t_code = Teacher.t_code;
Outcome Table (5 rows):
| Code | Series | t_code | Designation |
|---|---|---|---|
| E_2215 | 2020 | T1 | Head |
| E_4127 | 2021 | T2 | AP |
| E_1203 | 2022 | T3 | AP |
| E_2219 | 2021 | T3 | AP |
NULL | NULL | T4 | Lecturer |
Explanation: Teacher T4 has no matching course row. T4 appears with NULL for Code and Series.
Retains all records from both relations. Non-matching fields are filled with NULL.
Relational algebra:
Courses⟗TeacherMySQL query:
SELECT Courses.Code, Courses.Series, Courses.t_code, Teacher.Designation
FROM Courses
LEFT JOIN Teacher ON Courses.t_code = Teacher.t_code
UNION
SELECT Courses.Code, Courses.Series, Teacher.t_code, Teacher.Designation
FROM Courses
RIGHT JOIN Teacher ON Courses.t_code = Teacher.t_code;
Outcome Table (5 rows):
| Code | Series | t_code | Designation |
|---|---|---|---|
| E_2215 | 2020 | T1 | Head |
| E_4127 | 2021 | T2 | AP |
| E_1203 | 2022 | T3 | AP |
| E_2219 | 2021 | T3 | AP |
NULL | NULL | T4 | Lecturer |
Explanation: All courses find a teacher match. The unmatched teacher T4 is preserved with NULL for Code and Series.
Check.
Tuple count verification:
Exam tip.
Include the relational algebra expression alongside each MySQL query. It shows strong mastery and helps lock in full marks.
Sources.
Topic: T05.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · Section A · 2 (Repeated question: Also asked in 2018 | Solved in T05)
Question.
Write down the SQL queries for following operations:
i) Create table for student (roll, name, dept)
ii) Insert one example entry for student tbale
iii) Modify the student table to student (roll, name, dept, session)
iv) Show the roll and name of the students of ECE dept only.
(Note: "tbale" printed verbatim in original paper; refers to table)
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: T04.2 · Write RA queries on a given schema · Section B · 2 (Repeated question: Also asked in 2019 | Solved in T04)
Question.
Consider the following relation database:
Patient (Patient_ID, Patient_Name, Mobile)
History (Patient_ID, Symptom, Date)
Report (Patient_ID, Corona_center, Test_result)
Now, write down the relational algebra (Not SQL) to find out the following queris:
i) Find the names of those patients who have fever symptom
ii) Find out the mobile numbers of those patients who have provided samples in Rangpur corona center and their results have become positive.
(Note: "relation database" and "queris" printed verbatim in original paper; refers to relational database and queries)
Answer.
What the examiner wants.
Four relational algebra queries worth 2 marks each. Covers selection on joined tables and daily grouping with peak aggregation. Also tests multi-table filtering and set intersection between history and lab test reports.
Key idea.
Link patients to clinical records via Patient_ID. Natural joins equate common keys. For part (ii), group by Date and count patients, then find the global maximum of these daily totals.
Step-by-step solution.
Assumption: In relation Report, Parient_ID is a typographical misprint for Patient_ID.
(i) Names of patients who have fever symptom:
History where Symptom = "fever".Patient on Patient_ID.(ii) Maximum number of suspected patients (high-fever symptom) on a date:
Date and count the patients on each date:(iii) Mobile numbers of patients tested in Rajshahi corona center with positive results:
Report for center "Rajshahi" and test result "positive".Patient on Patient_ID.Mobile:(iv) Names of patients who have high fever symptom but negative test result:
Patient, and project their names:Short version for 2024 Q.5(a) (Sec B, 4 marks, CO2):
Answer parts (i) and (ii) only. Part (i) matches part (i) above. Part (ii) targets Rangpur instead of Rajshahi:
Check.
Suppose:
History: (P1, "high-fever", "2020-04-01"), (P2, "high-fever", "2020-04-01"), (P3, "high-fever", "2020-04-02").
Report: (P1, "Rajshahi", "negative"), (P2, "Rajshahi", "positive").
Part (ii): Count on 2020-04-01 is 2. Count on 2020-04-02 is 1. The max operation yields 2.
Part (iv): Thigh={P1,P2,P3}. Tneg={P1}. Intersection is {P1}. The query correctly retrieves P1's name.
Exam tip.
When a question repeats across years with only a city name swapped, the query structure is identical. Memorize the two-step pattern for daily extremes: group by date with count, then apply scalar max.
Sources.
[Lecture Deck 02 · Slides 11–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)
Topic: T05.7 · Multi-table business-schema query sets (MySQL): Covid, Company, Insurance, E-commerce · Section B · 2 (Repeated question: Also asked in 2020 | Solved in T05)
Question.
Define RDMS. Consider the following insurance database where the primary keys are underlined.
Person (driver_id, name, address)
Car (license, model, year)
Accident (report_no, data, location)
Owner (driver_id, license)
Participated (driver_id, report_no, car, damage_amount)
Write MySQL for the following queries –
i) Find the number of accidents in which the cars belonging to “John Smith” were involved.
ii) Add a new accident to the database, assuming any values for required attributes.
iii) Update the car “Mazda” belonging to “John”.
iv) Update the damage amounts $3000 for the car with license number “YJK-100” in the accident with report number “APR2197”.
(Note: "RDMS" and "data" printed verbatim in original paper; refers to RDBMS and date)
Answer.
What the examiner wants.
Definition of RDBMS (printed as "RDMS", ~2 marks) followed by four distinct SQL statements (1.5 marks each in 2020; 1 mark each in 2024):
INSERT INTO Accident statement with sample literals.UPDATE statement modifying a vehicle record through an ownership join.UPDATE statement setting damage amounts on a composite primary key match.Key idea.
In an insurance database, vehicle ownership (Owner) is distinct from accident participation (Participated). John Smith's car could be driven by someone else during an accident; joining Participated.car to Owner.license links accidents back to the car's owner.
Step-by-step solution.
Definition of RDBMS: An RDBMS (Relational Database Management System) is a database management software based on the relational model of data. It stores information in tables (relations) of rows and columns, enforces data integrity using keys and constraints, and provides a structured declarative query language (SQL) for retrieval and manipulation.
(i) Number of accidents involving cars owned by "John Smith":
SELECT COUNT(DISTINCT p.report_no) AS accident_count
FROM Participated p
JOIN Owner o ON p.car = o.license
JOIN Person per ON o.driver_id = per.driver_id
WHERE per.name = 'John Smith';
(ii) Add a new accident with sample values:
INSERT INTO Accident (report_no, date, location)
VALUES ('AR-2024-01', '2024-10-15', 'Dhaka-Rajshahi Highway');
(iii) Update the car "Mazda" belonging to "John":
Assumption: The query updates the manufacturing year of John's Mazda to 2022.
UPDATE Car c
JOIN Owner o ON c.license = o.license
JOIN Person p ON o.driver_id = p.driver_id
SET c.year = 2022
WHERE p.name = 'John'
AND c.model = 'Mazda';
(Alternative standard SQL subquery:
UPDATE Car
SET year = 2022
WHERE model = 'Mazda'
AND license IN (
SELECT o.license
FROM Owner o
JOIN Person p ON o.driver_id = p.driver_id
WHERE p.name = 'John'
);
)
(iv) Update damage amount to $3,000 for car "YJK-100" in accident "APR2197":
UPDATE Participated
SET damage_amount = 3000
WHERE car = 'YJK-100'
AND report_no = 'APR2197';
Variant for 2024 Q.5(b) (6 marks): The same RDBMS definition and four queries directly solve the question.
Check.
Validation of part (i):
Participated has multiple rows with the same report_no.COUNT(DISTINCT p.report_no) counts that accident exactly once rather than overcounting.Exam tip.
MySQL natively supports multi-table UPDATE ... JOIN ... SET syntax; showing both the MySQL join update and the standard SQL IN subquery covers all grading rubrics.
Sources.
Deck 03 · Slides 18, 30, 56, 58–59, Textbook Ch. 3 §3.4, §3.9.
Topic: T05.6 · Subqueries theory ("two examples"): IN, SOME/ALL, EXISTS, scalar, correlated, WITH · Section B · 2
Question. Explain sub-queries with two suitable examples.
Answer.
What the examiner wants.
A conceptual explanation of what a subquery is in SQL, followed by two well-structured, distinct query examples (e.g., set membership IN and scalar aggregate comparison) with explanations of how the inner and outer queries interact (2 marks for theory/structure, 1 mark per example).
Key idea.
A subquery embeds one SELECT statement inside another. Instead of writing multiple separate programs to retrieve intermediate data, a subquery passes intermediate sets or single scalar values directly to the outer query's predicates.
Step-by-step solution.
Explanation: A subquery (or nested query) is a SELECT statement embedded inside another SQL statement (the outer query). It can appear in the WHERE clause to filter tuples, in the FROM clause as a temporary derived relation, or in the SELECT clause as a scalar expression. Subqueries allow multi-step data retrieval in a single query.
Example 1: Set Membership Subquery (IN)
Find all courses offered in Fall 2017 that were also offered in Spring 2018:
SELECT DISTINCT course_id
FROM section
WHERE semester = 'Fall' AND year = 2017
AND course_id IN (
SELECT course_id
FROM section
WHERE semester = 'Spring' AND year = 2018
);
The inner subquery generates the set of courses running in Spring 2018. The outer query checks whether Fall 2017 courses belong to that generated set.
Example 2: Scalar Comparison Subquery (AVG)
Find instructors whose salary is higher than the average salary of all instructors:
SELECT name, salary
FROM instructor
WHERE salary > (
SELECT AVG(salary)
FROM instructor
);
The inner query computes a single numeric value (the overall average salary). The outer query evaluates the > predicate against this scalar value for each instructor.
Variant for 2019 Q.8(b) (4 marks): Presenting the two SQL examples with their purpose answers the question.
Check.
Execution mechanisms:
IN), the subquery produces a unary relation {c1,c2,…}. The outer query performs membership testing (t∈R).scalar), the subquery reduces to a single numerical value (e.g., 65,000). The outer query compares each instructor's salary attribute directly against this scalar.Exam tip.
Pair one set membership example (IN) with one aggregate scalar example (AVG) to demonstrate broad SQL competence.
Sources.
Deck 03 · Slides 35–43, 52, Textbook Ch. 3 §3.8.
Topic: T07.3 · Implement a trigger or stored procedure · Section B · 3
Question. An e-commerce system wants to automate actions when a new order is inserted such as updating stock and sending email. Implement a database trigger that handles this workflow.
Answer.
What the examiner wants.
An AFTER INSERT trigger on the orders table that automates post-order actions: updating product inventory (2 marks) and queueing email dispatch (2 marks). The answer must address the architectural reality of sending emails from within a database.
Key idea.
A database engine manages transactional data on disk. It cannot open network sockets or send SMTP emails directly. Doing so inside a database transaction would introduce huge network latencies, hold table locks, and create single points of failure. The standard engineering pattern updates stock directly and inserts an email job into an email_queue table. An external application service polls this queue and sends the actual email over the network.
Step-by-step solution.
Assumption: The tables are orders(order_id, product_id, quantity, customer_email), products(product_id, stock), and email_queue(queue_id, recipient, subject, body, queued_at).
A trigger runs inside the database engine and cannot send external emails directly.
Instead, the trigger updates product stock and inserts a row into an email_queue table. An external mailer application reads this queue and sends the email.
DELIMITER //
CREATE TRIGGER trg_after_order_insert
AFTER INSERT ON orders
FOR EACH ROW
BEGIN
-- 1. Deduct ordered quantity from product stock
UPDATE products
SET stock = stock - NEW.quantity
WHERE product_id = NEW.product_id;
-- 2. Enqueue email notification for external mailer service
INSERT INTO email_queue (recipient, subject, body, queued_at)
VALUES (
NEW.customer_email,
'Order Confirmation',
CONCAT('Your order #', NEW.order_id, ' for product #', NEW.product_id, ' (Qty: ', NEW.quantity, ') has been placed successfully.'),
NOW()
);
END //
DELIMITER ;
Check.
Trace with concrete sample tuples:
products(5, 50).INSERT INTO orders VALUES (501, 5, 4, 'customer@example.com');.orders.trg_after_order_insert fires immediately.products.stock becomes 50−4=46.email_queue with recipient 'customer@example.com' and order details.Exam tip.
Include the single-line note explaining that triggers cannot dispatch network emails directly. Then show the message queue pattern. Examiners award full marks for this practical engineering insight.
Sources.
Topic: T09.1 · ACID properties · Section B · 3 (Repeated question: Also asked in 2017 | Solved in T09)
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: T05.4 · Aggregate functions (theory) · Section B · 1
Question.
Define aggregated functions.
EMPLOYEE (EID, Name, Department, Salary)
SALES (SID, EID, SaleAmount, SaleDate)
The management wants to reward the top-earing department. Write a SQL query to find the total salary paid per department.
(Note: "top-earing" printed verbatim in original paper; refers to top-earning)
Answer.
What the examiner wants.
Formal definition of aggregate functions (1 mark) and a concise GROUP BY aggregation query calculating total departmental salary from the EMPLOYEE table (2 marks).
Key idea.
When a summary value must be calculated for each category (each department), the query groups records by the category column and applies the SUM aggregate function to the grouped partitions.
Step-by-step solution.
Definition: An aggregate function is a built-in SQL function that takes a collection of values across a column (or within subsets defined by GROUP BY) and returns a single summarizing scalar value. Standard SQL provides five primary aggregate functions: AVG, MIN, MAX, SUM, and COUNT.
Query:
SELECT Department,
SUM(Salary) AS Total_Salary
FROM EMPLOYEE
GROUP BY Department;
Check.
Trace with sample rows:
GROUP BY Department forms two partitions:SUM(Salary) = 110,000SUM(Salary) = 70,000Exam tip.
Only join extra tables (SALES) if the question explicitly requires attributes from both tables.
Sources.
Deck 03 · Slides 30–32, Textbook Ch. 3 §3.7.
Topic: T05.8 · Short notes: ON DELETE CASCADE, GROUP BY, ORDER BY, AS · Section B · 1
Question.
Write short note on the following statements –
i) ON CASCADE DELETE
ii) Group By
iii) Order By
iv) As
Answer.
What the examiner wants.
Concise technical descriptions, purpose, and standard SQL syntax/examples for four fundamental SQL clauses and constraint actions (1 mark each).
Key idea.
Each term serves a distinct role in relational data management: ON DELETE CASCADE governs referential integrity maintenance; GROUP BY partitions data for summary aggregation; ORDER BY controls output presentation order; AS introduces aliasing for projection expressions and relation names.
Step-by-step solution.
i) ON DELETE CASCADE (printed as "ON CASCADE DELETE"):
A foreign key referential integrity action. When a tuple in the parent table is deleted, the DBMS automatically deletes all corresponding referencing tuples in the child table. This maintains referential integrity and prevents orphaned records.
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY (course_id) REFERENCES course(course_id)
ON DELETE CASCADE
);
ii) GROUP BY:
An SQL clause used to partition table rows into distinct groups having identical values in specified columns. Aggregate functions (COUNT, SUM, AVG, MIN, MAX) then compute summary statistics for each individual group.
SELECT dept_name, AVG(salary) AS avg_sal
FROM instructor
GROUP BY dept_name;
iii) ORDER BY:
An SQL clause that sorts query result rows in ascending (ASC, default) or descending (DESC) order based on one or more attributes. Multiple sort keys break ties sequentially.
SELECT name, salary
FROM instructor
ORDER BY salary DESC, name ASC;
iv) AS:
An SQL keyword used to define an alias (an alternative temporary name). It can rename an attribute or computed expression in the SELECT clause for readability, or rename a table in the FROM clause to shorten table references and enable self-joins.
SELECT salary * 1.15 AS revised_salary
FROM employee AS e;
Short version for 2019 Q.8(c) (4 marks): Provide parts (i) and (ii).
Short version for 2023 Q.6(c) (2 marks): Provide part (i) with definition, syntax, and effect.
Check.
Referential trace of ON DELETE CASCADE:
department.course have dept_name = 'Biology'.department via DELETE FROM department WHERE dept_name = 'Biology' automatically removes the three referencing courses from course.Exam tip.
For short notes on SQL statements, always supply both the formal definition and a minimal code snippet illustrating syntax.
Sources.
Deck 03 · Slides 8, 20, 24, 32, Deck 04 · Slide 4, Textbook Ch. 3 §3.4, §3.6, §3.7, Textbook Ch. 4 §4.4.5.
Topic: T12.4 · RAID levels, comparison, and recovery role · Section B · 3
Question. A multimedia archive contains very large image and video files. RAID is recommended for storage. Compare different RAID levels.
Answer.
What the examiner wants.
A comparison of RAID levels evaluated specifically for a multimedia archive workload (large sequential files, read-heavy, rare updates), concluding with an explicit recommendation (RAID 6 or RAID 5) and a brief justification.
Key idea.
Large media files demand high capacity efficiency and high read bandwidth. Parity schemes (RAID 5 and 6) are much more cost-effective than mirroring. RAID 6 is the safer choice because rebuilding large multi-terabyte drives takes days.
Step-by-step solution.
Multimedia archives store multi-gigabyte image and video files. The workload consists of high-throughput sequential reads (streaming, downloading), rare updates (write-once, read-many), and very high total capacity demands.
| RAID Level | Striping Unit | Redundancy Mechanism | Fault Tolerance | Usable Storage Capacity | Read Speed (Large Files) | Write Speed |
|---|---|---|---|---|---|---|
| RAID 0 | Block | None | 0 disks | 100% | Very Fast | Very Fast |
| RAID 1 | Block / Drive | Mirroring (copy) | 1 disk per pair | 50% | Fast | Moderate |
| RAID 5 | Block | Distributed Parity | 1 disk | NN−1 (High) | Very Fast | Fast for sequential |
| RAID 6 | Block | Distributed P + Q | 2 disks | NN−2 (High) | Very Fast | Moderate |
| RAID 1+0 | Block | Mirroring + Striping | 1 disk per pair | 50% | Very Fast | Very Fast |
Check.
Quick self-test:
Exam tip.
Start by identifying the workload (large files, read-heavy), present a structured comparison table, and conclude with a 2-line recommendation of RAID 6.
Sources.
Topic: T09.5 · Concurrency problems · Section B · 3 (Repeated question: Also asked in 2018 | Solved in T09)
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: 1 mark for naming the 5 anomalies, 2 marks for schedule tables and explanation.
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:
Below are the full schedule tables for the two primary 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 (update by T1 of −50 is lost!) |
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads initial balance 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 local A=150 | |
| t6 | write(A) | Database updated to A=150 | |
| t7 | commit | T2 commits with invalid data | |
| t8 | abort (Rollback) | T1 fails and aborts; recovery restores A=100 |
T2 based its computation on a temporary value that never officially existed, leaving the database inconsistent.
Check.
Quick self-test:
Exam tip.
For 3- or 4-mark questions, list the five anomalies and pick Lost Update and Dirty Read as your primary two detailed schedule examples. They are the cleanest to draw and the most convincing to examiners.
Sources.
Topic: T11.6 · Timestamp ordering: R-TS/W-TS rules, trace a schedule; rolled-back transaction gets a NEW timestamp · Section B · 3 (Repeated question: Also asked in 2018 | Solved in T11)
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 · 3
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. Extraction of read/write operations (1 mark), finding conflicts for items A and B (1.5 marks), precedence graph and cycle detection (1 mark), and concluding verdict (0.5 marks).
Key idea. The question presents blocks of operations per column. We convert them into a chronological timeline of database reads and writes. A conflict exists whenever two transactions touch the same item and at least one writes. If opposite conflicting directions exist, a cycle forms.
Step-by-step solution.
Because we have both T1→T2 and T2→T1, there is an immediate cycle on item A.
Item B also creates conflicting dependencies in both directions: T2→T1 and T1→T2.

The precedence graph consists of vertices {T1,T2} and 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.
Check.
Exam tip. RUET repeated this exact question from 2018. Writing the steps clearly with step numbers gives maximum marks.
Sources.
← Prev: 2023 | Exam-Style Layer | Original Question Paper | Next: ClassTestQuestions →