88.0 KB · commit 40bb182
| year | 2020 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2020 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 72 |
| time | 3 Hours |
| layer | explanation |
← Prev: 2019 | Exam-Style Layer | Original Question Paper | Next: 2021 →
Topic: T01.3 · Functions of the DBA and relation schema · Section A
Question. What are the five main functions of a database administrator? What is relation schema?
Answer.
What the examiner wants.
The five official functions of a DBA (3 marks, following the exact terminology from Deck 01 Slide 10) and the definition of a relation schema with a formal example (2 marks).
Key idea.
The Database Administrator (DBA) is the person with centralized control over the database system. The DBA handles both physical storage decisions and user authorization. A relation schema is the logical structural definition of a table (its blueprint).
Step-by-step solution.
Five Main Functions of a Database Administrator (DBA):
Relation Schema:
A relation schema is the formal logical definition or blueprint of a relation (table). It specifies the name of the relation along with its set of attributes (columns) and their corresponding domains (data types).
Variant for 2021 Q.1(b) (3 marks): State and explain the five DBA functions above; omit the relation schema.
Variant for 2017 Q.1(c) (2 marks): List only the names: (1) Schema definition, (2) Storage structure and access-method definition, (3) Schema and physical-organization modification, (4) Granting of authorization for data access, (5) Routine maintenance.
Check.
Quick self-test:
Exam tip.
Examiners check off the exact 5 headings from Slide 10. Write the exact headings and underline them.
Sources.
Topic: T01.7 · Two-tier vs three-tier architecture · Section A
Question. Differentiate between the two-tier architecture and three-tier architecture of database. Which is better suited for web application? Why?
Answer.
What the examiner wants.
Key differences between two-tier and three-tier database architectures (1.5 marks), and a definitive choice of three-tier for web applications with technical justification (1.5 marks).
Key idea.
In two-tier systems, the client communicates directly with the database system. In three-tier systems, an application server sits between the client and the database. Web applications require three-tier architecture so client browsers remain lightweight and never access database ports directly.
Step-by-step solution.
Differences between Two-Tier and Three-Tier Architectures:
| Feature | Two-Tier Architecture | Three-Tier Architecture |
|---|---|---|
| Application Placement | The application logic resides entirely on the client machine. | The client holds only the presentation layer. Application logic resides on an intermediate application server. |
| Database Communication | The client invokes database system calls directly over the network (using ODBC or JDBC). | The client communicates with the application server, which in turn contacts the database system. |
| Client Overhead | Thick (fat) client. Requires database drivers and business code installed on each client. | Thin client. Runs in a web browser or simple mobile interface. |
Figure: Two-tier and three-tier database architectures (Deck 01, Slide 30)
Web Application Choice & Reason:
Three-tier architecture is better suited for web applications.
Check.
Quick self-test:
Exam tip.
State your verdict in bold font: Three-tier architecture is better suited for web applications. Then supply the two key reasons: thin clients and security/connection pooling.
Sources.
Topic: T02.3 · Mapping cardinality and participation constraints · Section A
Question. What is mapping cardinalities? Define different types of cardinalities.
Answer.
What the examiner wants.
Definition of mapping cardinalities (1 mark). Formal definitions and examples for each of the four binary cardinality ratios: 1:1, 1:N, N:1, and M:N (3 marks).
Key idea.
Mapping cardinalities place limits on the number of relationship instances an entity can join. In a binary relationship between sets A and B, arrows in the E-R diagram denote "one" and undirected lines denote "many".
Step-by-step solution.
Mapping Cardinality:
Mapping cardinality specifies how many entities from one entity set can be associated with entities from another entity set through a binary relationship set.
Types of Mapping Cardinalities:
One-to-One (1:1):
dept_head).One-to-Many (1:N):
Many-to-One (N:1):
Many-to-Many (M:N):
See also: 2018 Q.1(c) (tests participation constraints) and CT-02 Q.02 (identifies entities, keys, relationships, and cardinalities).
Check.
Quick self-test:
Exam tip.
Use bullet points with the format: name, formal rule, and everyday university schema example.
Sources.
Topic: T04.2 · Write RA queries on a given schema · Section A
Question.
Consider the following relation schema:
person(id, name, age)
vaccine(id, center, dose_no, date)
Now give expression in relational algebra to express-
(i) Find the names of all persons who are adult.
(ii) Find the names of all persons who have taken the 1st dose only.
(iii) Find the details of all persons who were given vaccine from "RMC" center and completed 2nd dose.
Answer.
What the examiner wants.
Three relational algebra expressions worth 2 marks each. Tests simple attribute filtering, the relational set difference operator (−) for an "only" query condition, and join filtering on multiple attributes.
Key idea.
A person with two doses has a record for dose 1 and another record for dose 2. Selecting dose_no = 1 alone will incorrectly return two-dose individuals. To find persons taking dose 1 only, subtract IDs with dose 2 from IDs with dose 1.
Step-by-step solution.
Assumption: An adult is defined as a person with age≥18. The attribute vaccine.id references person.id.
(i) Names of all adult persons:
Select persons with age 18 or older, then project their names:
Πname(σage≥18(person))(ii) Names of all persons who have taken the 1st dose only:
person on id and project the names:Equivalently, written as a single expression:
Πname(person⋈(Πid(σdose_no=1(vaccine))−Πid(σdose_no=2(vaccine))))(iii) Details of all persons vaccinated from "RMC" center who completed 2nd dose:
vaccine table for center "RMC" and dose number 2:person on id:To restrict output to person attributes only:
Πperson.id,name,age(person⋈Trmc2)Check.
Sample data:
person: (1, "Rahim", 25), (2, "Karim", 17), (3, "Sara", 30).
vaccine: (1, "RMC", 1, "2021-01"), (1, "RMC", 2, "2021-02"), (3, "DMC", 1, "2021-01").
Part (i): Rahim and Sara have age ≥18. Output: {"Rahim", "Sara"}.
Part (ii): Tdose1={1,3}. Tdose2={1}. Difference {1,3}−{1}={3}. Join yields {"Sara"}. Rahim is excluded because he completed dose 2.
Part (iii): Rahim matches RMC and dose 2. Join retrieves Rahim's full record.
Exam tip.
When an exam query says "only", use relational set difference (−). Subtract the forbidden set from the desired set.
Sources.
[Lecture Deck 02 · Slides 11–24](../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: T03.2 · Keys: super / candidate / primary / alternate / composite / foreign · Section A
Question. Write short note about: Super Key, Candidate Key, Primary Key, and Foreign Key.
Answer.
What the examiner wants.
Four distinct short notes. The mark split is 1 mark per key. Each short note must provide a definition, its core technical property, and a concrete example.
Key idea.
Do not write long essays for short notes. Provide a clean structure for each key: Definition, Key Property, and Example using a single table.
Step-by-step solution.
1. Super Key:
2. Candidate Key:
3. Primary Key:
NOT NULL). It should rarely or never change.4. Foreign Key:
dept_name in Student is a foreign key referencing Department(dept_name).Check.
Self-test check:
NOT NULL.Exam tip.
Spend about 2.5 minutes per note. Keep all examples rooted in the same Student table to save precious exam time.
Sources.
Topic: T02.4 · Weak vs strong entity sets · Section A (Repeated question: Also asked in 2018 | Solved in T02)
Question. Explain the difference between a weak and a strong entity set with appropriate example.
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.8 · EER: aggregation · Section A (Repeated question: Also asked in 2018 | Solved in T02)
Question. What is aggregation in ER-model design?
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: T05.7 · Multi-table business-schema query sets (MySQL): Covid, Company, Insurance, E-commerce · Section A
Question.
Consider the following company database schema.
employee(ssn, fname, lname, DoB, Address, Sex, Salary, dept_no)
department(dnumber, dname, mgr_ssn, mgr_start_date)
dept_location(dnumber, dlocation)
project(pnumber, pname, dnum)
works_on(essn, pno, hours)
dependent(essn, dependent_name, Sex, DoB, relationship)
Now write down the MySQL query for the followings.
(i) For each department whose average salary is more than $30,000, retrieve the department_name and the number of employees working for that department.
(ii) Find the names of all employees who are working on project number "5" and are from the same department.
(iii) Find the number of dependent people of those employees who are from "H&R" department.
Answer.
What the examiner wants.
Three enterprise-schema queries (parts (i) and (ii) worth ~3.5 marks, part (iii) worth ~3 marks):
HAVING AVG(Salary) > 30000.works_on), and project tables while enforcing that the employee's department matches the project's controlling department (dnum).Key idea.
Complex relational databases separate entities into normalized tables. Queries require traversing relationships: employee to department via dept_no = dnumber, employee to project via works_on, and employee to dependents via essn = ssn.
Step-by-step solution.
(i) Department name and employee count for departments with average salary > $30,000:
SELECT d.dname AS department_name,
COUNT(e.ssn) AS number_of_employees
FROM department d
JOIN employee e ON d.dnumber = e.dept_no
GROUP BY d.dnumber, d.dname
HAVING AVG(e.Salary) > 30000;
(ii) Names of employees working on project 5 who belong to the department controlling project 5:
Assumption: "from the same department" means the employee's department matches the department controlling project 5 (e.dept_no = p.dnum).
SELECT e.fname, e.lname
FROM employee e
JOIN works_on w ON e.ssn = w.essn
JOIN project p ON w.pno = p.pnumber
WHERE p.pnumber = 5
AND e.dept_no = p.dnum;
(iii) Total number of dependents for employees in the "H&R" department:
SELECT COUNT(dp.dependent_name) AS total_dependents
FROM dependent dp
JOIN employee e ON dp.essn = e.ssn
JOIN department d ON e.dept_no = d.dnumber
WHERE d.dname = 'H&R';
Check.
Trace of part (ii):
dept_no = 1) works on Project 5 (dnum = 1). 1 = 1 matches ⟹ included.dept_no = 2) works on Project 5 (dnum = 1). 2 = 1 does not match ⟹ excluded (working on the project from a different department).
The predicate e.dept_no = p.dnum correctly enforces departmental affiliation.Exam tip.
When a question says "from the same department" regarding a project, connect the employee's dept_no with the project's controlling department attribute dnum.
Sources.
Deck 03 · Slides 18–19, 30–34, Textbook Ch. 3 §3.4, §3.7.
Topic: T13.2 · SQL injection: how it works and prevention · Section A (Repeated question: Also asked in 2021 | Solved in T13)
Question. What is an SQL injection attack? Explain how it works and what precautions must be taken to prevent SQL injection attack.
Answer.
What the examiner wants.
Definition of SQL injection (1 mark), a concrete example of how the attack operates (1.5 to 2 marks), and comprehensive technical precautions for prevention (2 marks).
Key idea.
SQL injection happens because the database cannot tell code apart from data when strings are glued together. Prepared statements separate the code structure (precompiled query plan) from the data (parameters). Even if a parameter contains SQL keywords or quotes, the database treats it only as a literal string.
Step-by-step solution.
1. What is an SQL Injection Attack?
An SQL injection attack occurs when an attacker inputs malicious SQL commands into an application input field. The application concatenates this untrusted input directly into a dynamic SQL query string. The database parser interprets the malicious input as SQL instructions rather than data. This allows the attacker to bypass authentication, read unauthorized data, or modify and delete tables.
2. How It Works
Consider an application that builds a query using string concatenation:
# Vulnerable query construction
query = "SELECT * FROM instructor WHERE name = '" + user_input + "'"
' OR '1'='1SELECT * FROM instructor WHERE name = '' OR '1'='1';
Mechanism: The quote closes the name literal. The '1'='1' condition is always true. The database returns all records in the instructor table.
Scenario 2: Destructive Attack (Piggybacked Query)
'; DROP TABLE student; -- SELECT * FROM instructor WHERE name = ''; DROP TABLE student; -- ';
DROP TABLE student statement. The trailing -- treats the remaining query syntax as a comment.3. Precautions to Prevent SQL Injection
Use Prepared Statements (Parameterized Queries): This is the primary defense. The application precompiles the SQL query structure with placeholders. User input is bound separately as data parameters. The parser never executes parameter content as SQL commands.
# Secure parameterized query
cursor.execute("SELECT * FROM instructor WHERE name = %s", (user_input,))
In Java/JDBC, use PreparedStatement with ? markers and setString().
Input Validation and Whitelisting: Validate data types, lengths, and patterns before passing them to queries. For dynamic query parts like table or column names that cannot use parameters, check input against an explicit whitelist of allowed identifiers.
Enforce Least Privilege:
Configure database user accounts with minimal necessary privileges. A public web application account should only have SELECT or INSERT access. It must never have administrative permissions like DROP TABLE or GRANT.
Use Parameterized Stored Procedures: Wrap database operations inside stored procedures with typed parameters. Do not concatenate dynamic SQL inside the stored procedure body.
Suppress Database Error Messages: Hide internal database error details, table names, and stack traces from end users. Display generic error pages instead.
Short version for 2020 Q.4(a) (4 marks): Provide the definition, the ' OR '1'='1 exploit example, and the three core precautions: prepared statements, input validation, and least privilege.
Check.
Replaying the attack in a prepared statement:
' OR '1'='1 into cursor.execute("SELECT * FROM instructor WHERE name = %s", (user_input,)), the database searches for an instructor whose literal name is the exact 10-character string ' OR '1'='1.Quick self-test:
ORDER BY columns?Exam tip.
Always show the input ' OR '1'='1 and the resulting query where '1'='1' makes the WHERE clause tautological. This guarantees full marks on "how it works".
Sources.
[Textbook Ch. 9 §9.8.1](../Textbook/Chapter_09_App_Development/Chapter%2009%20-%20Application%20Development.md)
[Textbook Ch. 5 §5.1.1.5](../Textbook/Chapter_05_Advanced_SQL/Chapter%2005%20-%20Advanced%20SQL.md)
Topic: T04.5 · Domain relational calculus · Section A
Question.
Let that, R=(A,B,C) and r1, r2 both be relations on the schema R. Give an expression in the domain relational calculus that is equivalent to each of the followings.
(i) πA(r1)
(ii) r1∪r2
(iii) r1∩r2
Answer.
What the examiner wants.
Three Domain Relational Calculus (DRC) expressions worth 1 mark each. Evaluates the ability to translate projection, union, and intersection from relational algebra into predicate formulas over domain variables.
Key idea.
Domain relational calculus uses domain variables corresponding to relation attributes rather than whole-tuple variables. A query expression has the form:
For a schema R=(A,B,C), each relation instance consists of 3-tuples ⟨a,b,c⟩. Projection uses the existential quantifier (∃) to bind omitted attributes. Union uses logical disjunction (∨). Intersection uses logical conjunction (∧).
Step-by-step solution.
Let domain variables a,b,c range over the domains of attributes A,B,C respectively.
(i) Domain calculus for πA(r1):
This formula states: "the set of all values a such that there exist values b and c where ⟨a,b,c⟩ is a tuple in r1."
(ii) Domain calculus for r1∪r2:
(iii) Domain calculus for r1∩r2:
Check.
Quick self-test:
Exam tip.
Always match the arity of the angle-bracketed domain variables on the left of the vertical bar to the arity of the resulting relation.
Sources.
[Lecture Deck 02 · Slides 9–10](../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: T06.2 · Join outcome tables · Section A
Question.
Consider the following tables:
Courses
| Teacher
|
Answer.
What the examiner wants.
The exact resulting relations for all four join operations on the given instance (about 1.25 marks per sub-question). Examiners verify correct attributes, accurate row counts, and proper NULL values.
Key idea.
Both relations share the join attribute t code. In Courses, the teacher codes are T1, T2, and T3 (T2 appears twice). In Teacher, the codes are T1, T2, T3, and T4. Every course has a matching teacher. But teacher T4 has no courses assigned. Natural and left joins produce 4 rows. Right and full joins preserve T4 with NULL in the course columns, giving 5 rows.
Step-by-step solution.
Assumption: The attribute "t code" is the common join key between Courses and Teacher.
The common attribute is t code. In SQL statements, it is written as `t code`.
Matches tuples where t code is identical and outputs 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 |
|---|---|---|---|
| ECE 2215 | 2017 | T1 | Head |
| ECE 4127 | 2016 | T2 | Professor |
| ECE 1203 | 2019 | T3 | Lecturer |
| ECE 2219 | 2017 | T2 | Professor |
Explanation: Every course has a matching teacher. T4 in Teacher has no course, so it is omitted.
Preserves all rows from the left table (Courses). Missing right attributes get 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 |
|---|---|---|---|
| ECE 2215 | 2017 | T1 | Head |
| ECE 4127 | 2016 | T2 | Professor |
| ECE 1203 | 2019 | T3 | Lecturer |
| ECE 2219 | 2017 | T2 | Professor |
Explanation: All t code values in Courses (T1, T2, T3) exist in Teacher. No NULL padding is needed. The result matches the Natural Join.
Preserves all rows from the right table (Teacher). Unmatched rows get NULL in Courses columns.
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 |
|---|---|---|---|
| ECE 2215 | 2017 | T1 | Head |
| ECE 4127 | 2016 | T2 | Professor |
| ECE 2219 | 2017 | T2 | Professor |
| ECE 1203 | 2019 | T3 | Lecturer |
NULL | NULL | T4 | Lecturer |
Explanation: Teacher T4 has no matching course. It appears with NULL for Code and Series.
Retains all rows from both tables. Missing attributes from either side are padded 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 |
|---|---|---|---|
| ECE 2215 | 2017 | T1 | Head |
| ECE 4127 | 2016 | T2 | Professor |
| ECE 2219 | 2017 | T2 | Professor |
| ECE 1203 | 2019 | T3 | Lecturer |
NULL | NULL | T4 | Lecturer |
Explanation: Combines all matching rows plus unmatched teacher T4 with NULL values.
Check.
Tuple count verification:
t code: (ECE 2215, T1), (ECE 4127, T2), (ECE 2219, T2), (ECE 1203, T3). Total = 4 matched tuples.Exam tip.
Always count the tuples before drawing the tables. If all left tuples find a match, the Left Outer Join result is identical to the Natural Join.
Sources.
Topic: T02.2 · Attribute types · Section B
Question.
Differentiate between-
(i) Simple and composite attribute
(ii) Single-valued and multi-valued attribute
Answer.
What the examiner wants.
Clear pairwise distinctions: 2 marks for simple vs composite, and 2 marks for single-valued vs multi-valued. The examiner looks for definitions, divisibility, storage impact, and concrete examples.
Key idea.
Attributes describe entities. Some attributes are indivisible (simple), while others contain smaller subparts (composite). Similarly, some attributes hold only one value per record (single-valued), while others can hold a set of values (multi-valued).
Step-by-step solution.
(i) Simple vs Composite Attribute:
| Feature | Simple (Atomic) Attribute | Composite Attribute |
|---|---|---|
| Definition | Cannot be divided into smaller subparts. | Can be divided into smaller subparts that form independent attributes. |
| Structure | Holds a single atomic value from its domain. | Forms a hierarchy of component attributes. |
| E-R Notation | Single ellipse connected to the entity rectangle. | An ellipse connected to component ellipses. |
| Storage / Schema | Maps to a single column in a relational table. | Flattened into separate columns for each subpart. |
| Example | salary, student_id, credits | name (first_name, last_name), address (street, city, zip_code) |
(ii) Single-Valued vs Multi-Valued Attribute:
| Feature | Single-Valued Attribute | Multi-Valued Attribute |
|---|---|---|
| Definition | Holds at most one value for a specific entity instance. | Can hold a set of values for a single entity instance. |
| Values per Entity | Exactly one value per record. | Zero, one, or multiple values per record. |
| E-R Notation | Single ellipse. | Double ellipse (concentric ellipses). |
| Table Conversion | Stored directly in the main entity table. | Converted into a separate table with the entity primary key. |
| Example | date_of_birth, roll_no, nid | phone_numbers, degrees, email_addresses |
Check.
Quick self-test:
date_of_birth.Exam tip.
Use two separate comparison tables. This shows structure immediately and guarantees all 4 marks.
Sources.
Topic: T09.3 · Transaction states / life-cycle diagram · Section B
Question. What is a transaction? Describe the life cycle of a transaction.
Answer.
What the examiner wants.
Definition of a transaction (1 mark), followed by a description of the 5 states of its execution lifecycle (2 marks), and the state transition diagram (1 mark).
Key idea.
A transaction functions as a finite state machine. It begins in the Active state, executes its code, enters Partially Committed after the last statement, and either successfully Commits or encounters an error, enters Failed, and Aborts.
Step-by-step solution.
Definition:
A transaction is a logical unit of program execution that accesses and possibly updates various data items in a database.
Life Cycle of a Transaction:
A transaction moves through five distinct states during its execution:
Figure: Transaction State Transition Diagram (Source: Deck 07, Slide 8)
Check.
Quick self-test:
Exam tip.
Draw the five state boxes with arrows before writing prose. A neat diagram guarantees full marks on the lifecycle part.
Sources.
Topic: T10.2 · Conflict equivalence by swapping (proof) · Section B
Question. Draw a concurrent schedule equivalent to serial schedule. Prove its step by step swapping process.
Answer.
What the examiner wants. A drawn concurrent schedule table (1.5 marks), a clear statement of the swapping rule (0.5 marks), and the numbered step-by-step swap sequence that yields a serial schedule (2 marks).
Key idea. In an interleaved schedule, operations on different data items do not interfere. If transaction T2 operates on item A while transaction T1 operates on item B, they do not conflict. We can safely push T1's operations to the left (earlier) and T2's operations to the right (later) by swapping adjacent pairs until all T1 operations precede all T2 operations.
Step-by-step solution.
Let T1 and T2 be two transactions operating on items A and B:
We draw the concurrent schedule S, where T2's operations on A are interleaved before T1's operations on B:
| Step | T1 | T2 |
|---|---|---|
| 1 | read(A) | |
| 2 | write(A) | |
| 3 | read(A) | |
| 4 | write(A) | |
| 5 | read(B) | |
| 6 | write(B) | |
| 7 | read(B) | |
| 8 | write(B) |
Two adjacent instructions Ii and Ij can be swapped if and only if they do not conflict. Since Ii accesses item A and Ij accesses item B, they access distinct data items (A=B). Therefore, they never conflict and can be swapped without changing the result of the schedule.
We move T1's instructions on B ahead of T2's instructions on A:
Initial Instruction List:
Swap 1: Swap adjacent instructions at positions 4 and 5 (T2:write(A) and T1:read(B)).
Swap 2: Swap adjacent instructions at positions 3 and 4 (T2:read(A) and T1:read(B)).
Swap 3: Swap adjacent instructions at positions 5 and 6 (T2:write(A) and T1:write(B)).
Swap 4: Swap adjacent instructions at positions 4 and 5 (T2:read(A) and T1:write(B)).
The instructions now form a serial schedule S′ where T1 executes completely, followed by T2:
| Step | T1 | T2 |
|---|---|---|
| 1 | read(A) | |
| 2 | write(A) | |
| 3 | read(B) | |
| 4 | write(B) | |
| 5 | read(A) | |
| 6 | write(A) | |
| 7 | read(B) | |
| 8 | write(B) |
This is the serial schedule ⟨T1,T2⟩.
Result: Since schedule S was transformed into serial schedule ⟨T1,T2⟩ through 4 valid swaps of non-conflicting adjacent instructions, S is conflict equivalent to ⟨T1,T2⟩ and is conflict serializable.
Check.
Exam tip. Always draw the initial interleaved schedule in table form first. Then number each swap explicitly and state: "Different items, so non-conflicting."
Sources.
Topic: T10.3 · Precedence-graph test → cycle → serial order(s) · Section B
Question.
Which of the following schedule is (conflict) serializable? For each serializable schedule, determine the equivalent serial schedules.
(i) r1(X);r3(X);w1(X);r2(X);w3(X)
(ii) r1(X);r3(X);w3(X);w1(X);r2(X)
Answer.
What the examiner wants. Independent analysis of schedule (i) (3 marks) and schedule (ii) (3 marks). For each schedule, list all conflicting pairs, construct the precedence graph, test for cycles, and give equivalent serial schedules if serializable.
Key idea. Both schedules operate on a single item X across three transactions T1,T2,T3. Any two operations from different transactions conflict if at least one is a write. We check each pair chronologically to build the precedence graph for each schedule.
Step-by-step solution.
Step-by-step conflict analysis on item X:
Summary of directed edges:
T1⟶T3,T3⟶T1,T1⟶T2,T2⟶T3
Cycle detection:
Verdict for (i): The precedence graph contains cycles. Schedule (i) is NOT conflict serializable. There is no equivalent serial schedule.
Step-by-step conflict analysis on item X:
Summary of directed edges:
T1⟶T3,T3⟶T1,T3⟶T2,T1⟶T2
Cycle detection:
Verdict for (ii): The precedence graph contains a cycle. Schedule (ii) is NOT conflict serializable. There is no equivalent serial schedule.
Conclusion: Neither schedule (i) nor schedule (ii) is conflict serializable.
Check.
Exam tip. Label each edge with the operation pair that creates it (for example, r1(X)→w3(X)). This leaves no room for marks deduction.
Sources.
Topic: T10.5 · View serializability (3 conditions, blind writes) · Section B
Question.
What is view serializability? Why do we need view serializability? Check the view serializability of the following schedule if any.
| T1 | T2 |
|---|---|
| R(X) | |
| W(X) | |
| R(X) | |
| W(X) | |
| R(Y) | |
| W(Y) | |
| R(Y) | |
| W(Y) |
Answer.
What the examiner wants. Formal definition of view serializability with all three conditions (2 marks), explanation of why it is needed and the role of blind writes (2 marks), and testing the given schedule against the serial schedule (2 marks).
Key idea. Conflict serializability is based on swapping non-conflicting adjacent instructions. Sometimes a schedule produces the exact same read flows and final state as a serial schedule, but cannot be swapped because of "blind writes" (writes with no preceding read). View serializability is a broader definition that focuses on who reads whose writes and who writes last.
Step-by-step solution.
A schedule S is view serializable if it is view equivalent to some serial schedule S′.
Two schedules S and S′ with the same set of transactions are view equivalent if the following three conditions hold for every data item Q:
We represent the given schedule S in table form:
| Step | T1 | T2 | Data Item |
|---|---|---|---|
| 1 | R(X) | X | |
| 2 | W(X) | X | |
| 3 | R(X) | X | |
| 4 | W(X) | X | |
| 5 | R(Y) | Y | |
| 6 | W(Y) | Y | |
| 7 | R(Y) | Y | |
| 8 | W(Y) | Y |
We test whether S is view equivalent to the serial schedule S′=⟨T1,T2⟩:

All three conditions are fully satisfied with respect to the serial schedule ⟨T1,T2⟩. (Also, the precedence graph has only edges T1→T2, meaning S is also conflict serializable).
Result: The schedule is view serializable, equivalent to the serial schedule:
⟨T1,T2⟩Check.
Exam tip. Whenever a schedule has no blind writes and is conflict serializable, it is automatically view serializable. Mentioning this connection demonstrates strong conceptual understanding.
Sources.
Topic: T11.4 · Deadlock: conditions, prevention vs detection, wait-for graph, victim selection · Section B
Question. What is deadlock? Describe the time-shared locking protocol with example.
Answer.
What the examiner wants.
The question asks for the definition of deadlock (1 mark) and a description of the "time-shared locking protocol" with an example (3 marks). As noted in the course syllabus, "time-shared locking protocol" is an exam misprint for Two-Phase Locking (2PL). The examiner expects the two phases of 2PL, the lock point, and an example schedule.
Key idea.
State the misprint assumption right away so the examiner sees your grasp of the syllabus. Explain that 2PL enforces growing and shrinking phases to ensure serializability. Provide a short 4-step example showing locks acquired, lock point, and unlocks.
Step-by-step solution.
Assumption: "Time-shared locking protocol" is an exam misprint for the Two-Phase Locking (2PL) protocol.
1. Deadlock:
A deadlock is an execution state where two or more transactions wait indefinitely for locks held by each other. Neither transaction can proceed, and external system rollback is required to resolve the block.
2. Two-Phase Locking (2PL) Protocol:
The Two-Phase Locking protocol ensures conflict serializability by requiring that each transaction acquires and releases locks in two distinct phases:
Lock Point:
The point in time where a transaction acquires its final lock is its lock point. Serializability is guaranteed in the order of transaction lock points.

Figure: Two-Phase Locking Protocol (Source: Deck 08, Slide 13)
3. Example:
Consider transaction T1 modifying accounts A and B:
| Step | Action | Phase |
|---|---|---|
| 1 | lock-S(A); read(A) | Growing |
| 2 | lock-X(B); read(B); write(B) | Growing (Lock Point) |
| 3 | unlock(A) | Shrinking begins |
| 4 | unlock(B) | Shrinking |
Because all locks precede the first unlock, T1 obeys 2PL and guarantees serializability.
Check.
Self-test:
Exam tip.
Start your answer with the explicit assumption line. Then deliver the textbook 2PL definition and table.
Sources.
Topic: T05.7 · Multi-table business-schema query sets (MySQL): Covid, Company, Insurance, E-commerce · Section B
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, date, 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: Printed as "RDMS" in original question paper; refers to "RDBMS")
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: T07.1 · What a trigger is, its purposes, and its syntax · Section B (Repeated question: Also asked in 2018 | Solved in T07)
Question. What is triggering? What are the purposes of using triggering? Write the syntax for creating a 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: T08.8 · Normalize an unnormalized table → 1NF → 2NF → 3NF · Section B
Question.
Consider the given structure below:
| Proj. Num. | Proj. Name | Emp. No. | Emp. Name | Job Class | Chg/Hr | Hrs. Biller. | Total Charge |
|---|---|---|---|---|---|---|---|
| 13 | Banking | 103 | John | Analyst | 500 | 8 | 4000 |
| 105 | Steve | Programmer | 300 | 8 | 2400 | ||
| 26 | Telecom | 115 | Jim | Business Analyst | 100 | 10 | 1000 |
| 717 | Joe | Engineer | 300 | 7 | 2100 | ||
| 39 | Finance | 113 | David | Team Leader | 1000 | 4 | 4000 |
| 120 | Jian | DBA | 800 | 3 | 2400 |
Proj. Num. and Proj. Name cells span both employee rows for each project)
Answer.
What the examiner wants.
Part (i): Identification of data redundancy and concrete examples of update, insertion, and deletion anomalies (3 marks). Part (ii): Complete normalization progression to 1NF, 2NF, and 3NF with sample rows and primary keys (5 marks).
Key idea.
The table has merged project cells (violating 1NF) and derived calculations (Total Charge = Chg/Hr * Hrs. Biller.). It mixes project data, employee data, job classification rates, and project assignments. Unmerge the cells, drop the derived attribute, isolate partial dependencies into separate tables (2NF), and remove the transitive job charge rate dependency (3NF).
Step-by-step solution.
Proj. Name is repeated for every employee assigned to the same project.Total Charge is a derived attribute (Total Charge=Chg/Hr×Hrs. Biller.). Storing calculated values wastes space and creates data inconsistency risks.Chg/Hr) for a job class (e.g., "Programmer") changes, multiple rows across different projects must be updated. Missing a single row produces conflicting hourly rates.Emp. No. is part of the primary key and cannot be NULL.(Note: We use Hrs_Billed to denote the column printed as "Hrs. Biller.")
Identified Functional Dependencies:
Fill in the merged project cells so that each row represents an atomic, complete record:
| Proj_Num | Proj_Name | Emp_No | Emp_Name | Job_Class | Chg_Hr | Hrs_Billed |
|---|---|---|---|---|---|---|
| 13 | Banking | 103 | John | Analyst | 500 | 8 |
| 13 | Banking | 105 | Steve | Programmer | 300 | 8 |
| 26 | Telecom | 115 | Jim | Business Analyst | 100 | 10 |
| 26 | Telecom | 717 | Joe | Engineer | 300 | 7 |
| 39 | Finance | 113 | David | Team Leader | 1000 | 4 |
| 39 | Finance | 120 | Jian | DBA | 800 | 3 |
PK: (Proj_Num, Emp_No)
Remove partial dependencies on the composite key (Proj_Num, Emp_No):
Decomposed into three relations:
PROJECT(Proj_Num, Proj_Name) with PK Proj_NumEMPLOYEE_2NF(Emp_No, Emp_Name, Job_Class, Chg_Hr) with PK Emp_NoASSIGNMENT(Proj_Num, Emp_No, Hrs_Billed) with PK (Proj_Num, Emp_No)In EMPLOYEE_2NF, there is a transitive dependency:
We decompose EMPLOYEE_2NF into EMPLOYEE and JOB.
PROJECT
| Proj_Num | Proj_Name |
|---|---|
| 13 | Banking |
| 26 | Telecom |
| 39 | Finance |
PK: Proj_Num
JOB
| Job_Class | Chg_Hr |
|---|---|
| Analyst | 500 |
| Programmer | 300 |
| Business Analyst | 100 |
| Engineer | 300 |
| Team Leader | 1000 |
| DBA | 800 |
PK: Job_Class
EMPLOYEE
| Emp_No | Emp_Name | Job_Class |
|---|---|---|
| 103 | John | Analyst |
| 105 | Steve | Programmer |
| 115 | Jim | Business Analyst |
| 717 | Joe | Engineer |
| 113 | David | Team Leader |
| 120 | Jian | DBA |
PK: Emp_No | FK: Job_Class references JOB(Job_Class)
ASSIGNMENT
| Proj_Num | Emp_No | Hrs_Billed |
|---|---|---|
| 13 | 103 | 8 |
| 13 | 105 | 8 |
| 26 | 115 | 10 |
| 26 | 717 | 7 |
| 39 | 113 | 4 |
| 39 | 120 | 3 |
PK: (Proj_Num, Emp_No) | FKs: Proj_Num references PROJECT(Proj_Num), Emp_No references EMPLOYEE(Emp_No)
Check.
Lossless join check:
PROJECT joins with ASSIGNMENT on Proj_Num (key of PROJECT).EMPLOYEE joins with ASSIGNMENT on Emp_No (key of EMPLOYEE).JOB joins with EMPLOYEE on Job_Class (key of JOB).Exam tip.
Explicitly state that Total Charge is dropped because it is a calculated attribute. This shows the examiner that you understand schema optimization.
Sources.
← Prev: 2019 | Exam-Style Layer | Original Question Paper | Next: 2021 →