40.4 KB · commit 40bb182
| document_type | Class Test Question Solutions |
|---|---|
| course_code | ECE 2215 |
| course_title | Database Systems |
| full_marks | 80 |
| total_tests | 4 |
| layer | exam-style |
← Prev: 2024 | Explanation Layer | Original CT Questions | Directory Overview →
| Parameter | Details |
|---|---|
| Institution | Rajshahi University of Engineering & Technology (RUET) |
| Department | Electrical & Computer Engineering |
| Test Title | CT-01 |
| Marks | 20 |
| Time | 30 minutes |
| Curriculum Standard | With CO Mapping |
Topic: T01.4 · Data abstraction levels, schemas and instances · CT-01 · CO1
Question. Define data abstraction. Describe different types of data abstractions.
Answer.
Purpose of Data Abstraction:
A database contains complex data structures, storage blocks, and indexing schemes. Most end users and programmers are not trained in low-level storage details. Data abstraction hides this physical complexity. It simplifies user interactions, enforces security, and enables physical data independence.
Levels of Data Abstraction:
type instructor = record
ID : string;
name : string;
dept_name : string;
salary : integer;
end;
Figure: Three levels of data abstraction (Deck 01, Slide 14)
Variant for 2019 Q.2(a) (4 marks): Define data abstraction, describe the three levels, and include the diagram.
Variant for CT-01 Q.01 (5 marks): State the definition, explain the three levels, show the record example, and draw the diagram.
Topic: T03.3 · Referential integrity & FK syntax (MySQL) · CT-01 · CO1
Question. Draw a schema diagram for ECE, including 5 tables (Students, Courses, Instructors, Classroom, Results).
Answer.
1. Relational Schemas and Keys:
2. Relational Schema Diagram:
In Silberschatz style, each table is shown as a box with its attributes. Primary keys are underlined. Directed arrows point from foreign key attributes to the referenced primary keys.
Figure: Relational schema diagram for ECE with 5 tables and foreign key references.
Topic: T01.7 · Two-tier vs three-tier architecture · CT-01 · CO1
Question. Describe the structure of a database application.
Answer.
A database application connects user interfaces to the database engine through three functional layers:
Topic: T04.3 · Explain an RA expression in words · CT-01 · CO1
Question. Relations:
Write the relational algebra expressions for the following conditions using the relations above.
(Note: Sub-parts are numbered v, vi, vii, viii on the original question script).
Answer.
(v) Rename relation STUDENT as S and display Student_ID and Name:
ΠStudent_ID,Name(ρS(STUDENT))(vi) Student_ID, Name, and Course_Name for CSE students with Marks ≥80:
Filter students in CSE and courses with marks 80 or higher, join on Student_ID, and project:
(vii) Student_ID and Name of students in either STUDENT or ALUMNI:
Project both relations to the same attributes to satisfy union compatibility, then take the union:
ΠStudent_ID,Name(STUDENT)∪ΠStudent_ID,Name(ALUMNI)(viii) Number of students in each department:
Group STUDENT by department name and count the student identifiers:
Topic: T04.4 · Extended RA: aggregation · CT-01 · CO1
Question. Describe the following relational algebra expression:
iii.
ΠName(σMarks<50(STUDENT⋈STUDENT.Student_ID=COURSE.Student_IDCOURSE))iv.
Πcourse_id(σsemester="Fall"∧year=2017(section))−Πcourse_id(σsemester="Spring"∧year=2018(section))(Note: Sub-parts are numbered iii, iv on the original question script).
Answer.
(iii) Expression: ΠName(σMarks<50(STUDENT⋈STUDENT.Student_ID=COURSE.Student_IDCOURSE))
STUDENT and COURSE where STUDENT.Student_ID = COURSE.Student_ID to pair students with their course marks.Marks < 50.Name attribute and removes duplicates.(iv) Expression: Πcourse_id(σsemester="Fall"∧year=2017(section))−Πcourse_id(σsemester="Spring"∧year=2018(section))
course_id.course_id.| Parameter | Details |
|---|---|
| Institution | Rajshahi University of Engineering & Technology (RUET) |
| Department | Electrical & Computer Engineering |
| Test Title | CT-02 |
| Marks | 20 |
| Time | 20 minutes |
| Curriculum Standard | With CO Mapping |
Topic: T05.2 · DDL + DML warm-up: CREATE, INSERT, ALTER ... ADD, UPDATE, DELETE, rename, filter · CT-02 · CO2
Question. Consider the table and write SQL queries for the following queries:
STUDENT(StudentID,Name,Department,Semester,CGPA)[Marks: 02 | CO: CO2][Marks: 02 | CO: CO2][Marks: 03 | CO: CO2][Marks: 03 | CO: CO2]Answer.
SELECT *
FROM STUDENT
WHERE Department = 'ECE';
SELECT *
FROM STUDENT
WHERE Department = 'ECE' AND CGPA > 3.50
ORDER BY CGPA DESC;
SELECT *
FROM STUDENT
WHERE CGPA > (
SELECT AVG(CGPA)
FROM STUDENT
);
SELECT *
FROM STUDENT
WHERE CGPA = (
SELECT MAX(CGPA)
FROM STUDENT
WHERE CGPA < (
SELECT MAX(CGPA)
FROM STUDENT
)
);
Note on ties: This query identifies the unique second-highest distinct CGPA value. If multiple students share this exact second-highest CGPA, all tied students are displayed in the result.
Topic: T02.5 · Design a full E-R diagram for a scenario · CT-02 · CO3
Question. A university maintains information about Students, Courses, and Teachers. A student can enroll in several courses and each course can have many students. Each course is taught by one teacher, though a teacher may teach several courses.
[Marks: 04 | CO: CO3][Marks: 06 | CO: CO3]Answer.
(a) Identification of Components:
| Component | Type | Details | Primary Key |
|---|---|---|---|
| STUDENT | Entity Set | Attributes: student_id, name, email, dept_name | student_id |
| COURSE | Entity Set | Attributes: course_id, title, credits | course_id |
| TEACHER | Entity Set | Attributes: teacher_id, name, dept_name, phone | teacher_id |
| Enrolls | Relationship Set | Connects STUDENT and COURSE | (student_id, course_id) |
| Teaches | Relationship Set | Connects TEACHER and COURSE | course_id |
Cardinalities:
Enrolls): Many-to-Many (M:N). A student enrolls in several courses; each course has many students.Teaches): One-to-Many (1:N). A teacher teaches several courses; each course is taught by exactly one teacher.(b) Complete E-R Diagram:
Figure: University Enterprise Complete E-R Diagram
| Parameter | Details |
|---|---|
| Institution | Rajshahi University of Engineering & Technology (RUET) |
| Department | Electrical & Computer Engineering |
| Test Title | CT-03 |
| Marks | 20 |
| Time | 25 minutes |
| Curriculum Standard | With CO Mapping |
Topic: T08.4 · Attribute closure X+, F+, finding candidate keys · CT-03 · CO3
Question. Consider the relation:
ENROLLMENT(StudentID,StudentName,CourseID,CourseName,InstructorID,InstructorName,Grade)Assume the following functional dependencies:
StudentIDCourseIDInstructorID(StudentID,CourseID)→StudentName→CourseName,InstructorID→InstructorName→Grade[Marks: 04][Marks: 02][Marks: 02][Marks: 02]Answer.
To find all candidate keys, we analyze the attributes that must appear in every key.
Attributes not on any RHS: Examining the right-hand sides of the given functional dependencies:
Compute the Attribute Closure of {StudentID,CourseID}:
Check for Minimality: We check proper subsets of {StudentID,CourseID}:
Neither proper subset determines all attributes. Therefore, {StudentID,CourseID} is minimal.
Candidate Key={StudentID,CourseID}This is the only candidate key for the relation.
First, we determine the Candidate Key.
Attributes StudentID and CourseID never appear on the right-hand side of any functional dependency. Therefore, every candidate key must contain both attributes.
Computing the closure:
{StudentID,CourseID}+={StudentID,CourseID,StudentName,CourseName,InstructorID,InstructorName,Grade}Because no proper subset is a superkey, the unique Candidate Key is:
Candidate Key={StudentID,CourseID}Partial Dependencies: Occur when a non-prime attribute depends on a proper subset of a composite candidate key:
Transitive Dependencies: Occur when a non-prime attribute depends on another non-prime attribute:
Here, InstructorID is a non-prime attribute that determines the non-prime attribute InstructorName. From the primary key, we have (StudentID,CourseID)→InstructorID→InstructorName.
First Normal Form (1NF) Check:
All attributes hold atomic, single values. Therefore, the relation satisfies 1NF.
Second Normal Form (2NF) Check:
The candidate key is composite: {StudentID,CourseID}.
Prime attributes: {StudentID,CourseID}.
Non-prime attributes: {StudentName,CourseName,InstructorID,InstructorName,Grade}.
Examining the functional dependencies:
Both dependencies are partial functional dependencies. Because non-prime attributes depend on proper subsets of the candidate key, the relation violates 2NF.
Topic: T08.1 · Why normalize: redundancy and insert/update/delete anomalies · CT-03 · CO3
Question. Mention the problems caused by an unnormalized relation.
Answer.
Using databases without normalization causes four major problems:
Consider an unnormalized table storing student enrollment and instructor data:
| Student_ID | Student_Name | Course | Instructor | Instructor_Phone |
|---|---|---|---|---|
| S01 | Riad | DBMS | Dr. Hasan | 01711... |
| S01 | Riad | AI | Dr. Abdullah | 01811... |
| S02 | Zoha | DBMS | Dr. Hasan | 01711... |
Student_ID is part of the primary key and cannot be NULL.Short version for CT-03 Q.02 (3 marks): State the four problems (data redundancy, update anomaly, insertion anomaly, deletion anomaly). Give a brief two-line explanation and one table row example showing an inconsistent update.
Topic: T08.6 · Define normalization (and its importance) & 1NF / 2NF / 3NF · CT-03 · CO3
Question. Define normalization and state its main objective.
Answer.
Normalization is a formal, systematic technique for designing relational database schemas. It decomposes relations with anomalies into smaller, well-structured relations to reduce data redundancy and ensure data integrity.
Normalization is essential for relational databases because it:
Short version for CT-03 Q.03 (3 marks): Define normalization as the systematic decomposition of relations to minimize redundancy and eliminate anomalies. State the main objective: to produce well-structured tables free of insertion, update, and deletion anomalies while maintaining data consistency.
Topic: T08.9 · BCNF; 3NF vs BCNF; highest normal form · CT-03 · CO3
Question. Justify the statement: "Every BCNF relation is in 3NF, but every 3NF relation is not necessarily in BCNF."
Answer.
If a relation is in BCNF, every non-trivial FD α→β satisfies condition 1 (α is a superkey). Since condition 1 of 3NF is identical to the only condition of BCNF, every dependency that satisfies BCNF automatically satisfies 3NF. Thus, BCNF is a stricter subset of 3NF:
BCNF⊂3NFConsider relation R(A,B,C,D) with functional dependencies:
F={AB→CD,D→A}Find Candidate Keys:
Check 3NF:
Check BCNF:
Because relation R is in 3NF but not in BCNF, the statement is justified.
| Parameter | Details |
|---|---|
| Institution | Rajshahi University of Engineering & Technology (RUET) |
| Department | Electrical & Computer Engineering |
| Test Title | CT-04 |
| Marks | 20 |
| Time | 25 minutes |
| Curriculum Standard | With CO Mapping |
Topic: T09.1 · ACID properties · CT-04 · CO3
Question. Define a transaction? Explain the four ACID properties of a transaction with suitable examples.
Answer.
Definition:
A transaction is a logical unit of program execution that accesses and possibly updates various data items in a database. It consists of all operations executed between a begin transaction and an end transaction (commit or abort).
The Four ACID Properties with Examples:
Consider transaction T1 transferring $50 from account A (initially $1000) to account B (initially $2000):
Atomicity ("All-or-None"):
Consistency (Invariant Preservation):
Isolation (Shielding Concurrent Execution):
Durability (Permanence across Failures):
commit, updates A=950 and B=2050 are recorded to stable storage. If power fails a second later, the values remain intact upon reboot.Topic: T09.3 · Transaction states / life-cycle diagram · CT-04 · CO3
Question. Differentiate between a serial schedule and a concurrent schedule. Mention two advantages of concurrent execution of transactions.
Answer.
Difference Between Serial Schedule and Concurrent Schedule:
| Feature | Serial Schedule | Concurrent Schedule |
|---|---|---|
| Execution Pattern | Non-interleaved. One transaction runs to completion before another begins. | Interleaved. Operations from different transactions overlap in time. |
| Resource Use | Low. CPU remains idle while a transaction waits for disk I/O. | High. CPU processes one transaction while disk serves another. |
| Response Time | High average response time; short transactions wait behind long ones. | Low average response time; short transactions finish quickly. |
| Need for Concurrency Control | None. Execution is safe without concurrency control protocols. | Essential. Needs protocols (locks/timestamps) to avoid anomalies. |
Two Advantages of Concurrent Execution of Transactions:
Topic: T09.4 · Concurrent execution advantages and schedules · CT-04 · CO3
Question. Explains any two problems caused by concurrent execution.
(Note: Printed as "Explains any two problems caused by concurrent execution." in the original question script).
Answer.
If concurrency-control management is not implemented properly, uncoordinated interleaving violates transaction isolation. This causes five major anomalies:
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=500 | |
| t2 | A:=A−50 | T1 computes local A=450 | |
| t3 | write(A) | Database updated to A=450 | |
| t4 | write(A) | T2 performs blind write: A=25 | |
| t5 | commit | T1 commits | |
| t6 | commit | Final A=25 (T1's −50 update is lost!) |
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=100 | |
| t2 | A:=A+100 | T1 computes local A=200 | |
| t3 | write(A) | Database A=200 (uncommitted) | |
| t4 | read(A) | T2 reads dirty value A=200 | |
| t5 | A:=A−50 | T2 computes A=150 | |
| t6 | write(A) | Database A=150 | |
| t7 | commit | T2 commits with invalid data | |
| t8 | abort (Rollback) | T1 fails; log restores A=100 |
T2 based its computation on a temporary value that never officially existed, leaving the database inconsistent.
| Time | Transaction T1 | Transaction T2 | Database State / Note |
|---|---|---|---|
| t1 | read(A) | T1 reads A=500 | |
| t2 | read(A) | T2 reads A=500 | |
| t3 | A:=A+100 | T2 computes local A=600 | |
| t4 | write(A) | Database A=600 | |
| t5 | commit | T2 commits | |
| t6 | read(A) | T1 reads A=600 (reads different value!) |
| Time | Transaction T1 | Transaction T2 | Note |
|---|---|---|---|
| t1 | read(A) | read(A) | Both transactions read data item A |
| t2 | delete(A) | T1 deletes data item A and commits | |
| t3 | read(A) | T2 attempts to read A again, but item does not exist |
| Time | Transaction T1 | Transaction T2 | Database / Summary State |
|---|---|---|---|
| t1 | read(A) A:=A−50 write(A) | T1 updates A to 950 on disk | |
| t2 | sum:=0 read(C) sum:=sum+C | T2 reads C=1000⟹sum=1000 | |
| t3 | read(A) sum:=sum+A | T2 reads updated A=950⟹sum=1950 | |
| t4 | read(B) sum:=sum+B | T2 reads old B=1000⟹sum=2950 | |
| t5 | avg:=sum/3 commit | T2 reports avg=2950/3≈983.33 | |
| t6 | read(B) B:=B+50 write(B) commit | T1 adds 50 to B (B=1050 on disk) |
Variant for 2024 Q.8(a) (3 marks):
List the five anomalies, then provide the full schedule tables for Lost Update and Dirty Read.
Short version for CT-04 Q.03 (4 marks):
Select Lost Update and Dirty Read with their definitions and schedule tables above.
Topic: T10.2 · Conflict equivalence by swapping (proof) · CT-04 · CO3
Question. Determine whether the schedule is conflict serializable or not. If it is serializable, give the equivalent serial order.
| T1 | T2 | T3 |
|---|---|---|
| Write(A) | ||
| Read(A) | ||
| Write(B) | ||
| Write(B) | ||
| Write(B) | ||
| Write(A) | ||
| Read(B) | ||
| Read(B) |
Answer.
We number the instructions of the schedule chronologically from 1 to 8:

The edges of the graph are:
A directed cycle exists between T1 and T3:
T1⟷T3Result: The precedence graph contains a cycle. The schedule is NOT conflict serializable. No equivalent serial order exists.
← Prev: 2024 | Explanation Layer | Original CT Questions | Directory Overview →