85.2 KB · commit 40bb182
| year | 2021 |
|---|---|
| exam | B.Sc. Engineering 2nd Year Even Semester Examination, 2021 |
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 72 |
| time | 3 Hours |
| layer | explanation |
← Prev: 2020 | Exam-Style Layer | Original Question Paper | Next: 2023 →
Topic: T01.2 · File system vs DBMS · Section A · CLO1 (Repeated question: Also asked in 2017 | Solved in T01)
Question. Discuss four significant differences between a file-processing system and a DBMS.
Answer.
What the examiner wants.
Four distinct architectural differences between an operating system file processing system and a DBMS. The mark split is 1 mark per difference. Examiners expect key technical concepts: redundancy, ad-hoc access, data independence, and concurrency or crash recovery.
Key idea.
An operating system file stores a sequence of bytes. The OS does not understand the internal structure of the data inside the file. In contrast, a DBMS understands data structures, enforces relations and constraints, coordinates concurrent users, and guarantees recovery after system crashes.
Step-by-step solution.
| Feature | File Processing System | DBMS (Database Management System) |
|---|---|---|
| Data Redundancy & Inconsistency | Data is duplicated across multiple separate files. Different copies easily get out of sync. | Centralizes data storage. Normalization avoids duplication and keeps copies consistent. |
| Data Access & Retrieval | Programmers must write a new custom program in C or Java for each new query. | Users write declarative queries (like SQL) to retrieve ad-hoc data quickly without new code. |
| Data Isolation & Independence | Data structures and application code are tightly coupled. Changing a file structure breaks programs. | Provides data abstraction. Changes to physical storage structures do not affect application programs. |
| Concurrent Access & Recovery | Hard to coordinate simultaneous access. Multiple updates cause lost data. Crash recovery is manual. | Built-in concurrency control prevents conflicting updates. Automated logging and recovery preserve ACID properties. |
Variant for 2021 Q.1(a) (4 marks): The same four differences directly answer the question.
Check.
Quick self-test:
Exam tip.
Use a comparison table with clear feature titles. This layout allows the examiner to check off 1 mark per row in seconds.
Sources.
Topic: T01.3 · Functions of the DBA and relation schema · Section A · CLO1 (Repeated question: Also asked in 2020 | Solved in T01)
Question. What are the five main functions of a database administrator?
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: T03.3 · Referential integrity & FK syntax (MySQL) · Section A · CLO2
Question. How do we achieve referential integrity in DBMS? Provide necessary MySQL query with an appropriate example.
Answer.
What the examiner wants.
An explanation of how a DBMS enforces referential integrity (~2 marks) plus valid, executable MySQL DDL and DML queries showing table creation, constraints, violating insert behavior, and cascading options (~3 marks).
Key idea.
Referential integrity prevents orphan child records. In MySQL, you define it using FOREIGN KEY ... REFERENCES .... When someone attempts to insert a child row pointing to a nonexistent parent row, MySQL blocks the command with Error 1452.
Step-by-step solution.
1. How Referential Integrity is Achieved in DBMS:
Referential integrity ensures that relationships between tables remain consistent. It requires that any foreign key value in a referencing table must exist as a primary key value in the referenced table, or be NULL.
A DBMS achieves referential integrity through three mechanisms:
FOREIGN KEY ... REFERENCES clause.INSERT, UPDATE, and DELETE commands. It blocks any operation that creates orphan child records.CASCADE: Deleting or updating a parent row automatically deletes or updates matching child rows.SET NULL: Sets child foreign key columns to NULL when the parent row is deleted or updated.RESTRICT / NO ACTION: Default rule; rejects parent deletion or update if matching child rows exist.2. MySQL DDL Query Example:
-- Parent table (Referenced relation)
CREATE TABLE Department (
dept_name VARCHAR(20) PRIMARY KEY,
building VARCHAR(20),
budget DECIMAL(12, 2)
);
-- Child table (Referencing relation)
CREATE TABLE Student (
student_id INT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
dept_name VARCHAR(20),
FOREIGN KEY (dept_name) REFERENCES Department(dept_name)
ON DELETE CASCADE
ON UPDATE CASCADE
);
3. Operation and Violation Demonstration:
Populate a valid parent department:
INSERT INTO Department VALUES ('ECE', 'Academic Building 2', 500000.00);
INSERT INTO Student VALUES (101, 'Akib', 'ECE'); -- Allowed
Now attempt a violating insert with a nonexistent department:
INSERT INTO Student VALUES (102, 'Shuvo', 'ME');
MySQL System Response:
MySQL rejects the insert and raises an integrity violation error:
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`university`.`Student`, CONSTRAINT `student_ibfk_1` FOREIGN KEY (`dept_name`) REFERENCES `Department` (`dept_name`) ON DELETE CASCADE ON UPDATE CASCADE)
If 'ECE' is deleted from Department, ON DELETE CASCADE automatically deletes student 101. This keeps the database consistent.
Check.
MySQL execution trace:
INSERT INTO Department VALUES ('ECE', ...): Row added.INSERT INTO Student VALUES (101, 'Akib', 'ECE'): Check verifies that 'ECE' exists in Department.dept_name. Insertion succeeds.INSERT INTO Student VALUES (102, 'Shuvo', 'ME'): Check discovers 'ME' is absent from Department.dept_name. Transaction halts with ERROR 1452.Exam tip.
Write both the CREATE TABLE statements and the violating INSERT statement. Quoting MySQL Error 1452 shows genuine practical database expertise.
Sources.
Topic: T04.2 · Write RA queries on a given schema · Section A · CLO2
Question.
Consider the following relation schema:
customer (id, name, age, gender)
order (id, product, price, date)
Now, give expression in relational algebra to-
(i) find name of the customers who are male.
(ii) find name of all customers who have purchased car as product.
(iii) find the details of all customers who have purchased "phone" as product and the price is less than $300.
Answer.
What the examiner wants.
Three relational algebra expressions worth approximately 1.5, 1.5, and 2 marks. Evaluates single-table selection, natural join between customer and orders, and compound filtering combining string and numeric inequalities.
Key idea.
The attribute id serves as customer primary key and appears as foreign key in order. Natural join equates customer.id = order.id. Filter on product names and numerical price thresholds.
Step-by-step solution.
Assumption: The attribute order.id represents the customer identifier that placed the order.
(i) Names of male customers:
Select tuples from customer where gender is "male", then project the customer name:
(ii) Names of all customers who purchased car as product:
customer on id.(iii) Details of all customers who purchased "phone" priced under $300:
order relation for product "phone" with price strictly below 300:customer:To project customer attributes only:
Πcustomer.id,name,age,gender(customer⋈Ttarget_orders)Check.
Sample data:
customer: (101, "Kamal", 30, "male"), (102, "Nila", 24, "female").
order: (101, "phone", 250, "2021-05-10"), (102, "phone", 400, "2021-06-01"), (102, "car", 15000, "2021-07-15").
Part (i): Kamal has gender "male". Output: {"Kamal"}.
Part (ii): Order with product "car" belongs to ID 102. Natural join with customer outputs {"Nila"}.
Part (iii): Kamal's phone costs 250 (<300). Nila's phone costs 400 (<300). Result contains Kamal's record.
Exam tip.
When the question asks for "details of all customers", providing the joined relation or projecting the customer relation's attributes is accepted. Always state the join assumption on id.
Sources.
[Lecture Deck 02 · Slides 11–19](../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 · CLO1 (Repeated question: Also asked in 2023 | Solved in T03)
Question. Differentiate among Superkey, Candidate Key and Primary Key with an appropriate example.
Answer.
What the examiner wants.
Precise definitions and clear distinctions among the four key types. The mark split is 1 mark per key type. The examiner expects minimality rules, nullability constraints, and an illustrative relational table.
Key idea.
Think of a super key as any attribute set that uniquely identifies a row. A candidate key is a minimal super key: removing any attribute ruins uniqueness. The primary key is the single candidate key chosen by the database designer. A composite key is any key consisting of two or more attributes.
Step-by-step solution.
A key is an attribute or set of attributes used to identify rows in a table.
Distinctions Among Keys:
| Key Type | Definition | Minimality | NULL Allowed |
|---|---|---|---|
| (i) Primary Key | The candidate key chosen by the database designer to identify tuples uniquely. | Yes (minimal) | No (never allowed) |
| (ii) Candidate Key | A minimal super key. Removing any attribute destroys uniqueness. | Yes (strictly minimal) | Yes (unless constrained NOT NULL) |
| (iii) Super Key | Any set of attributes that uniquely identifies a row. May contain extra attributes. | No (can have redundant attributes) | No for identifying columns |
| (iv) Composite Key | A key that consists of two or more attributes rather than a single attribute. | Can be minimal (candidate) or non-minimal | Depends on whether it is PK or unique |
Relationship:
Primary Key⊆Candidate Keys⊆Super KeysRunning Example:
Consider relation Student(student_id,name,email,nid,dept_name):
| student_id | name | nid | dept_name | |
|---|---|---|---|---|
| 101 | Akib | akib@gmail.com | 1999123456 | ECE |
| 102 | Shuvo | shuvo@gmail.com | 2000654321 | ECE |
| 103 | Sakib | sakib@gmail.com | 2001987654 | ETE |
Short version for 2018 Q.2(a) (4 marks): Omit (iv) Composite key. Keep the definitions, distinctions table, and the Student running example for Super Key, Candidate Key, and Primary Key.
Short version for 2021 Q.2(b) (3 marks): Same as 2018 Q.2(a). Present the 3-row distinction table and the Student relation key classification.
Check.
Minimality and closure verification:
name) and cannot be a candidate key.Exam tip.
Write down the subset formula Primary Key⊆Candidate Keys⊆Super Keys right above your example. This gives the examiner an instant visual proof of your grasp.
Sources.
Topic: T04.3 · Explain an RA expression in words · Section A · CLO2
Question.
For each expression, explain in words what the expression does.
Where takes(id, course, sec_id, sem, year, grade)
(i) σyear≥2009(takes)⋈student
(ii) Πid,name,course_id(student⋈takes)
Answer.
What the examiner wants.
Accurate plain English descriptions of two relational algebra expressions (2 marks each). Evaluates understanding of selection, natural join semantics, projection, and attribute propagation.
Key idea.
Trace the operation tree from the innermost operators to the outermost operators. Explain what filtering or pairing takes place at each step, and describe what the final relation represents.
Step-by-step solution.
(i) Expression: σyear≥2009(takes)⋈student
takes relation and filters it. It keeps only the course enrollment records where the course was taken in the year 2009 or later.student relation on their common attribute id.name, dept_name, tot_cred) with all enrollment details (course, sec_id, sem, year, grade).(ii) Expression: Πid,name,course_id(student⋈takes)
id.name) and their enrolled course details (course_id / course).id), student name (name), and the course identifier (course_id / course). All other attributes (such as department name, section ID, semester, year, and grade) are discarded. Duplicate rows are removed automatically.Check.
(101, "Alice", "CS-101") and (101, "Alice", "CS-201").Exam tip.
Format your answer in three distinct bullet points: describe the inner operation, explain the outer operation, and give a one-sentence plain English summary of the final output.
Sources.
[Lecture Deck 02 · Slides 15–20](../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.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · Section A · CLO2
Question.
Consider the following E-comerce database:
client (c_no, name, city, state, baldue)
product (p_no, description, profit_percent, quantity, sell_price, cost_price)
salesman (s_no, name, city, state, sal_amount, target, sold_yearly, remarks)
Now write the appropriate MySql code to execute the following query:
(i) Change the city of client no "C0005" to "Barishal".
(ii) Delete all salesmen whose salaries are equal to 35000 Tk.
(iii) Add a column called "Telephone" of datatype numeric and size = '11' to the client table.
(iv) Find products whose selling price is more than 500. Calculate a new selling price as original price15. Rename the new column in the output as new_price.
(Note: "E-comerce" and "MySql" printed verbatim from original question paper)*
Answer.
What the examiner wants.
Four distinct MySQL statements (2 marks each):
UPDATE statement with SET and targeted WHERE clause.DELETE FROM statement with numeric equality comparison.ALTER TABLE statement specifying column name and data type NUMERIC(11).SELECT statement performing arithmetic calculation and renaming using AS.Key idea.
MySQL adheres to ANSI SQL DDL and DML standards for row-level modifications (UPDATE, DELETE), schema evolution (ALTER TABLE), and calculated output expressions (AS).
Step-by-step solution.
(i) Change city of client "C0005" to "Barishal":
UPDATE client
SET city = 'Barishal'
WHERE c_no = 'C0005';
(ii) Delete salesmen whose salary is 35000 Tk:
DELETE FROM salesman
WHERE sal_amount = 35000;
(iii) Add column "Telephone" of numeric type and size 11 to client table:
ALTER TABLE client
ADD Telephone NUMERIC(11);
(iv) Find products with sell_price > 500 and calculate new selling price:
SELECT p_no,
description,
sell_price,
sell_price * 15 AS new_price
FROM product
WHERE sell_price > 500;
Check.
Statement validation:
c_no = 'C0005', ensuring exactly one record is updated.sal_amount defined in the schema.NUMERIC(11) matches the requested numeric type with precision 11.sell_price * 15 is evaluated row by row and projected under the alias new_price.Exam tip.
Double check attribute names against the provided schema (sal_amount, not salary; sell_price, not price).
Sources.
Deck 03 · Slides 11, 14, 20, 54, 58, Textbook Ch. 3 §3.3, §3.4, §3.9.
Topic: T02.2 · Attribute types · Section A · CLO4
Question.
Define entity and attribute. Explain the following attributes-
(i) Multi-valued
(ii) Derived
(iii) Composite
Answer.
What the examiner wants.
Definitions of entity and attribute (1 mark total). Explanations of multi-valued, derived, and composite attributes with visual notations and examples (1 mark each, 3 marks total).
Key idea.
An entity is an object that exists in the real world. Attributes are the characteristics that describe it. The E-R model provides special graphical notation for attributes that hold sets of values, values computed on the fly, or values composed of parts.
Step-by-step solution.
ID = 22222, or a student).name, salary).Explanation of Attribute Types:
Multi-valued Attribute:
phone_numbers = {0171..., 0181...}).Derived Attribute:
age derived from current date minus date_of_birth.Composite Attribute:
name divided into first_name, middle_initial, and last_name.
Figure: Complex Attributes in ER Diagram Notation (Deck 05, Slide 19)
Check.
Quick self-test:
age not be stored directly as a base attribute?date_of_birth is always accurate.Exam tip.
Mention both the definition and the specific Chen diagram symbol (double ellipse, dashed ellipse, branched ellipse) for each attribute type.
Sources.
Topic: T05.7 · Multi-table business-schema query sets (MySQL): Covid, Company, Insurance, E-commerce · Section A · CLO2
Question.
Consider the following E-comerce database:
client (c_no, name, city, state, Baldue)
product (p_no, description, profit_percent, quantity, sell_price, cost_price)
salesman (s_no, name, city, state, sal_amount, target, sold_yearly, remarks)
order (order_no, client_no, order_date, delivery_address, salesman_no, del_type, del_date, order_status)
order_details (order_no, product_no, quantity_ordered, product_rate)
(i) Find the total value of each product sold.
(ii) Find the products and their quantities for the orders placed by client no "C0001" and "C0002".
(iii) Find the product no and description of the products not being sold.
(iv) Find if the product "Lyera Top" has been ordered by any client and print the client_no, name to whom it was sold.
(Note: "E-comerce" and "Lyera Top" printed verbatim from original question paper)
Answer.
What the examiner wants.
Four comprehensive queries on a five-table sales database (3 marks each):
IN ('C0001', 'C0002').NOT IN or NOT EXISTS).client, order, order_details, product) filtering on a specific product description string.Key idea.
In MySQL, the table name order is a reserved SQL keyword and must be escaped with backticks (`order`). Unsold products exist in product but have zero entries in order_details, making NOT IN or NOT EXISTS the appropriate selection mechanism.
Step-by-step solution.
(i) Total value of each product sold:
SELECT od.product_no,
p.description,
SUM(od.quantity_ordered * od.product_rate) AS total_value
FROM order_details od
JOIN product p ON od.product_no = p.p_no
GROUP BY od.product_no, p.description;
(ii) Products and quantities ordered by client "C0001" and "C0002":
SELECT o.client_no,
od.product_no,
p.description,
od.quantity_ordered
FROM `order` o
JOIN order_details od ON o.order_no = od.order_no
JOIN product p ON od.product_no = p.p_no
WHERE o.client_no IN ('C0001', 'C0002');
(iii) Product number and description of products not sold:
SELECT p_no, description
FROM product
WHERE p_no NOT IN (
SELECT DISTINCT product_no
FROM order_details
);
(Alternative using NOT EXISTS:
SELECT p.p_no, p.description
FROM product p
WHERE NOT EXISTS (
SELECT 1
FROM order_details od
WHERE od.product_no = p.p_no
);
)
(iv) Check if "Lyera Top" was ordered and display client number and name:
SELECT DISTINCT c.c_no, c.name
FROM client c
JOIN `order` o ON c.c_no = o.client_no
JOIN order_details od ON o.order_no = od.order_no
JOIN product p ON od.product_no = p.p_no
WHERE p.description = 'Lyera Top';
Check.
Trace of part (iii) anti-join:
product has keys {P01,P02,P03}.order_details records sales for {P01,P02}.SELECT DISTINCT product_no FROM order_details returns {P01,P02}.WHERE p_no NOT IN ({P01, P02}) evaluates to true only for P03. Product P03 is correctly reported.Exam tip.
Always escape SQL reserved keywords like `order` with backticks when used as table or column names in MySQL.
Sources.
Deck 03 · Slides 18, 30–32, 36, 46, Textbook Ch. 3 §3.4, §3.7, §3.8.
Topic: T02.1 · Entity sets, relationship sets, types of relationships · Section B · CLO1
Question. What is ER diagram? Illustrate different types of relationship that can be represented in ER diagram.
Answer.
What the examiner wants.
A concise definition of an Entity-Relationship (E-R) diagram (1 mark). An explanation and illustration of relationship types classified by their degree: unary (recursive), binary, and ternary (3 marks).
Key idea.
An E-R diagram models a business enterprise visually. It maps entities as rectangles, attributes as ellipses, and relationships as diamonds. The degree tells you how many entity sets take part in a relationship. Binary is by far the most common, but unary and ternary also exist.
Step-by-step solution.
An Entity-Relationship (E-R) diagram is a graphical tool used in database design. It represents the conceptual schema of an enterprise by depicting entities, their attributes, and the relationships among them.
The degree of a relationship set is the number of participating entity sets. Different types of relationships based on degree include:
Unary (Recursive) Relationship (Degree 1):
course entity related to another course entity via a prereq relationship (roles: course_id and prereq_id).Binary Relationship (Degree 2):
instructor and student linked by the advisor relationship.Ternary Relationship (Degree 3):
proj_guide linking instructor, student, and project.| Relationship Type | Degree | Description | Example |
|---|---|---|---|
| Unary (Recursive) | 1 | Association among entities of the same entity set | Course prereq Course |
| Binary | 2 | Association between two distinct entity sets | Instructor advisor Student |
| Ternary | 3 | Association among three distinct entity sets | Instructor, Student, Project proj_guide |
| n-ary | n | Association among n entity sets | Rare; usually decomposed into binary |
Check.
Quick self-test:
Exam tip.
Define the E-R diagram in two sentences. Then present the three degree types using a clear summary table with real examples from the lecture slides.
Sources.
Topic: T08.4 · Attribute closure X+, F+, finding candidate keys · Section B · CLO1
Question.
Compute the closure of the following set F of functional dependencies for relational schema r (A, B, C, D, E).
A→BC
CD→E
B→D
E→A
List the candidate Keys for R.
Answer.
What the examiner wants.
Demonstrating the closure computation of functional dependencies (2 marks), followed by finding all candidate keys with proof of minimality (2 marks).
Key idea.
Computing the full set F+ on a 5-attribute schema yields hundreds of dependencies. In an exam, state that F+ is too large to write in its entirety, compute the attribute closures of single attributes and relevant combinations, and derive key non-trivial dependencies using Armstrong's axioms. Then identify all minimal attribute sets whose closure is {A,B,C,D,E}.
Step-by-step solution.
The complete closure F+ contains over one hundred trivial and non-trivial dependencies, which is too large to write out fully.
We compute the attribute closures of each single attribute and pair under F:
A+:
B+:
C+:
D+:
E+:
Key Two-Attribute Closures:
Key Non-Trivial Functional Dependencies in F+ (derived using Armstrong's Axioms):
A candidate key is a minimal set of attributes whose closure contains all attributes {A,B,C,D,E}.
Check.
Verification of Candidate Keys:
Exam tip.
Compute single-attribute closures first. Once you see that A+=R and E+=R, you already have two candidate keys. Then test pairs containing C.
Sources.
Topic: T08.7 · 2NF test from an FD set · Section B · CLO1
Question.
Given a relation R (A, B, C, D) and functional dependency at FD = { AB → CD, B → C }. Determine whether the given R is in 2NF? If not, convert it into 2NF.
(Note: "functional dependency at FD" printed verbatim from original question paper)
Answer.
What the examiner wants.
Candidate key derivation and attribute classification (1 mark), identification of the partial dependency violating 2NF (1.5 marks), and correct decomposition into 2NF relations with candidate keys identified (1.5 marks).
Key idea.
Candidate key is AB. The dependency B→C has B on its left, which is only part of the key AB. Because C is a non-prime attribute depending on half the key, it is a partial dependency. Decompose to isolate B→C into its own relation.
Step-by-step solution.
Given relation R(A,B,C,D) and functional dependencies:
FD={AB→CD,B→C}A relation is in 2NF if it is in 1NF and no non-prime attribute depends on a proper subset of any candidate key.
Examine the dependencies:
Because a partial dependency exists (B→C), the relation R is NOT in 2NF.
To achieve 2NF, we decompose R by isolating the partial dependency into its own relation:
Verification:
Check.
Decomposition property check:
Exam tip.
Always show the intersection R1∩R2 and state that it forms a key for R1. This proves your decomposition is lossless.
Sources.
Topic: T08.5 · Canonical cover Fc (and how it differs from normalization) · Section B · CLO1
Question. Differentiate between normalization and canonical cover in DBMS.
Answer.
What the examiner wants.
A comparison table highlighting key differences in definition, goal, inputs, outputs, and operational level (3 marks).
Key idea.
Normalization restructures tables (schemas). Canonical cover simplifies functional dependencies (constraints). You often compute a canonical cover first so that normalization algorithms (like 3NF synthesis) run efficiently.
Step-by-step solution.
| Parameter | Normalization | Canonical Cover (Fc) |
|---|---|---|
| Definition | The process of decomposing relation schemas to eliminate redundancy and update/delete/insert anomalies. | A minimal, non-redundant set of functional dependencies equivalent to the original FD set (Fc≡F). |
| Primary Goal | Design high-integrity tables that eliminate anomalies and avoid data duplication. | Simplify the set of integrity constraints so DBMS updates can be validated with minimal overhead. |
| Input | A relation schema R and its functional dependencies F. | A set of functional dependencies F. |
| Output | A collection of decomposed relations {R1,R2,…,Rk} in a desired normal form (e.g., 3NF, BCNF). | A simplified functional dependency set Fc with no extraneous attributes and unique left-hand sides. |
| Level of Operation | Operates on the schema design level (splitting tables and foreign keys). | Operates purely on the mathematical dependency level (simplifying FDs). |
Check.
Quick self-test:
Exam tip.
Use 4 to 5 structured comparison rows. A comparison table is easier to read and earns maximum marks for 3-mark questions.
Sources.
Topic: T08.5 · Canonical cover Fc (and how it differs from normalization) · Section B · CLO1
Question.
Define Functional dependency. Consider the following functional dependency set:
FD={
A→BC,
CD→E,
B→D,
E→A
}
Find the canonical form of the FD set.
Answer.
What the examiner wants.
Formal mathematical definition of functional dependency (2 marks), followed by a complete step-by-step canonical cover derivation: union rule check, extraneous attribute testing on LHS and RHS, and the final canonical set (3 marks).
Key idea.
A canonical cover has no redundant attributes and no redundant dependencies, with each LHS combined. To test if an attribute is extraneous on the RHS, remove it and see if you can still derive it using the remaining dependencies. To test an attribute on the LHS, remove it and see if the reduced LHS can derive the RHS under the original dependencies.
Step-by-step solution.
A functional dependency (FD) is a constraint between two sets of attributes in a relation schema R.
Let α⊆R and β⊆R. The functional dependency:
α→βholds on R if, in every legal relation instance r(R), whenever any two tuples t1 and t2 have the same values for attributes in α, they must also have the same values for attributes in β:
If t1[α]=t2[α]⟹t1[β]=t2[β]We say α functionally determines β.
A canonical cover Fc satisfies two conditions:
Step 1: Apply the Union Rule to combine identical LHS
In the given set F={A→BC,CD→E,B→D,E→A}, the left-hand sides are A,CD,B,E. All left-hand sides are already unique.
Step 2: Test for Extraneous Attributes
Check A→BC:
Check CD→E:
Check B→D:
Both LHS and RHS have a single attribute. Neither can be removed without dropping the dependency entirely.
Check E→A:
Both LHS and RHS have a single attribute. Neither can be removed.
Step 3: Resulting Canonical Cover
Since there are no extraneous attributes, the canonical cover is:
(Note: In minimal cover form with singleton right-hand sides, the equivalent set is {A→B,A→C,CD→E,B→D,E→A}. Both representations are correct.)
Check.
Equivalence verification:
Exam tip.
Show the closure calculation for each extraneous attribute test explicitly. Even if the answer is "no attribute is extraneous", showing the test proves you know the algorithm.
Sources.
Topic: T08.1 · Why normalize: redundancy and insert/update/delete anomalies · Section B · CLO1
Question.
Consider the following table:
| st_id | Name | Course | Session | Fee | Dept |
|---|---|---|---|---|---|
| 101 | Devi | DBMS | 2022 | 90k | CS |
| 102 | Sona | DBMS | 2022 | 90k | CS |
| 103 | Varun | DBMS | 2022 | 90k | CS |
| 104 | Satish | DBMS | 2022 | 90k | CS |
| 105 | Amisha | DBMS | 2022 | 90k | CS |
Answer.
What the examiner wants.
Clear verification of data redundancy with attribute identification (1.5 marks), followed by an explanation of update, insertion, and deletion anomalies tailored to this exact table (2.5 marks).
Key idea.
Notice that all five students have identical course details: "DBMS", "2022", "90k", and "CS". The course fee and department depend on Course, not on the individual student st_id. Putting course facts into the student table creates textbook modification anomalies.
Step-by-step solution.
Yes, significant data redundancy exists.
The attributes Course ("DBMS"), Session ("2022"), Fee ("90k"), and Dept ("CS") are duplicated across all 5 rows. In this schema, Fee and Dept depend on Course, not on the primary key st_id. Storing course-level attributes in every student record creates column-level duplication.
st_id cannot be NULL due to the Entity Integrity constraint.Check.
Quick self-test:
Exam tip.
Start with a direct "Yes" to answer the first question immediately. Then present the anomalies with bullet points using the values printed in the question table.
Sources.
Topic: T09.1 · ACID properties · Section B · CLO1 (Repeated question: Also asked in 2017 | Solved in T09)
Question. Explain the ACID properties of transaction.
Answer.
What the examiner wants.
A concise definition of each of the four ACID properties. Examiners look for the specific database subsystem responsible for enforcing each property. The mark split is 1 mark per property (or 0.5 marks each in the 2-mark paper).
Key idea.
A transaction is a logical unit of database work. To keep data safe during crashes and concurrent access, the DBMS treats every transaction as an atomic, isolated unit that leaves data consistent and permanently saved.
Step-by-step solution.
A transaction is a logical unit of program execution that accesses and updates data items. To preserve data integrity during crashes and concurrent access, the DBMS must ensure the four ACID properties:
Atomicity ("All-or-None"):
Consistency (Preservation of Invariants):
Isolation (Shielding Concurrent Access):
Durability (Persistence):
Short version for 2024 Q.6(c) (2 marks):
Check.
Quick self-test:
Exam tip.
Start each bullet with the letter of the acronym, bold the property name, write a one-sentence definition, and end by naming the enforcing component.
Sources.
Topic: T10.3 · Precedence-graph test → cycle → serial order(s) · Section B · CLO3
Question.
Define conflict serializability. Check whether the following schedule is a conflict serializable or not.
| T1 | T2 |
|---|---|
| read(A) | |
| write(A) | |
| read(A) | |
| write(A) | |
| read(B) | |
| write(B) | |
| read(B) | |
| write(B) |
Answer.
What the examiner wants. Formal definition of conflict serializability (1 mark), conflict pair analysis (1.5 marks), precedence graph and serializability test (1 mark), and the equivalent serial order (0.5 marks).
Key idea. In this schedule, T1 finishes all operations on A before T2 touches A. Then T1 finishes all operations on B before T2 touches B. Because T1 precedes T2 on both items and T2 never executes anything before T1, all directed edges flow strictly from T1 to T2. There can be no cycles.
Step-by-step solution.
A schedule S is conflict serializable if it is conflict equivalent to some serial schedule. Two schedules are conflict equivalent if one can be transformed into the other by a sequence of non-conflicting adjacent instruction swaps.
We examine the 8 operations in order:
Conflicting pairs:
Every single conflict edge goes from T1 to T2. No operation in T2 precedes any conflicting operation in T1.

The graph contains two vertices {T1,T2} and a single directed edge:
T1⟶T2The graph is acyclic.
Result: The schedule is conflict serializable. The unique equivalent serial schedule is:
⟨T1,T2⟩Check.
Exam tip. Always explicitly state the equivalent serial order ⟨T1,T2⟩ whenever you conclude that a schedule is serializable.
Sources.
Topic: T10.3 · Precedence-graph test → cycle → serial order(s) · Section B · CLO3
Question.
Consider the following schedule:
| T1 | T2 |
|---|---|
| r(A) | |
| w(A) | |
| r(B) | |
| w(B) | |
| r(B) | |
| w(B) | |
| r(A) | |
| w(A) |
Answer.
What the examiner wants. Extraction of conflicts for A and B (1.5 marks), drawing the precedence graph (1.5 marks), cycle detection and answering the serial order question (1 mark).
Key idea. T1 acts first on item A, while T2 acts first on item B. This symmetry creates a forward edge T1→T2 on item A and a backward edge T2→T1 on item B. This results in a cycle.
Step-by-step solution.
All conflicting operations on item A require:
T1⟶T2All conflicting operations on item B require:
T2⟶T1
The precedence graph consists of:
This forms a directed cycle:
T1⟷T2Result: Because the precedence graph contains a cycle, the schedule is NOT serializable. Since it is not serializable, no order of execution exists.
Check.
Exam tip. Draw the graph clearly with circles for T1 and T2. Label the top arrow A and the bottom arrow B to clearly highlight the cycle.
Sources.
Topic: T11.4 · Deadlock: conditions, prevention vs detection, wait-for graph, victim selection · Section B · CLO1
Question.
What is deadlock? Consider the following wait-for-graph:
Determine whether the schedule contains any deadlock or not.
(Refer to the Wait-for-Graph Diagram and Detailed Text Representation below)
Answer.
What the examiner wants.
The definition of deadlock (1 mark), followed by a graph analysis of the provided wait-for graph: listing vertices and edges (1 mark), detecting the cycle (1.5 marks), giving the verdict and identifying the deadlocked transactions (1 mark), and explaining how to break the deadlock (0.5 marks).
Key idea.
A wait-for graph models who is waiting for whom. An arrow from Ti to Tj means Ti is waiting for Tj to release a lock. If you can follow arrows and return to where you started, you have a directed cycle. A cycle equals a deadlock. In this graph, T4→T5→T2→T4 forms a loop.
Step-by-step solution.
1. Deadlock Definition:
A deadlock is a situation where two or more transactions wait indefinitely for resources or data locks held by one another. None can continue without intervention.
2. Graph Structure:
From the diagram:
A directed edge Ti→Tj indicates that transaction Ti is waiting for a lock currently held by Tj.
3. Cycle Detection:
We examine the paths in the graph:
These three edges form a closed directed cycle:
T4→T5→T2→T44. Verdict:
Yes, the schedule contains a deadlock.
Deadlocked Transactions:
Transactions T2,T4, and T5 are deadlocked.
Note on remaining transactions: Transaction T1 has outgoing edges to T2,T3, and T4. It is blocked waiting for them, but it is not part of the cycle. Transaction T3 has no outgoing edges and is not blocked.
5. Deadlock Resolution:
The DBMS must resolve the deadlock by:
Check.
Cycle verification:
Exam tip.
Explicitly write out the cycle T4→T5→T2→T4 and state the three specific transactions involved.
Sources.
Topic: T13.2 · SQL injection: how it works and prevention · Section B · CLO4
Question. What is SQL injection attack? Describe the precautions that should be taken to prevent this 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: T02.4 · Weak vs strong entity sets · Section B · CLO1 (Repeated question: Also asked in 2018 | Solved in T02)
Question. Explain weak and 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.
← Prev: 2020 | Exam-Style Layer | Original Question Paper | Next: 2023 →