CUET MSc CSE · Admission Note · 02

Database Management Systems

Concept + worked examples + solved problems + exam-style MCQs. Porlei Silberschatz DBMS er selected chapter cover hoye jabe — boi ulto-palte porte hobe na.

Covers: Relational Model · SQL · Relational Algebra · ER Model · Normalization · Transactions

1 · Relational Model

Silberschatz Ch 1–2 · Keys, schema, integrity

Database holo connected data er ekta organized collection. Relational model e sob data table (relation) akare thake — row ar column diye.

Basic terms

TermMane kiExample
RelationEkta tableStudent table
TupleEkta row / recordek jon student er info
AttributeEkta columnname, roll
DomainAttribute er allowed value setage → 0–150 integer
DegreeColumn er sonkha4 column → degree 4
CardinalityRow er sonkha50 row → cardinality 50

Keys — sob theke important MCQ topic

Super Key

Je attribute (ba set of attributes) diye ekta row unique kore identify kora jay. Eta unique kintu extra attribute thakte pare.

Candidate Key

Minimal super key — jeta theke kono attribute bad dile r unique thake na. Ekta table e ekadhik candidate key thakte pare.

Primary Key

Candidate key gula theke bachai kora ekta key, ja main identifier hoy. NULL hote pare na, duplicate hote pare na.

Foreign Key

Ek table er attribute ja onno table er primary key ke reference kore — eta diye relationship toiri hoy.

Composite Key

Ekadhik attribute mile toiri primary key (ekta column eka unique kore na).

Mone rakho
Super Key ⊇ Candidate Key ⊇ Primary Key. Mane prottek candidate key ekta super key, kintu prottek super key candidate key noy.

Integrity Constraints

Solved Problem 1 Ekta table Enroll(student_id, course_id, semester, grade) e ekjon student ekta course ekbar-i nite pare per semester. Primary key ki?

Ekjon student ek course ekbar nite pare per semester — mane same student same course different semester e nite pare. Tai shudhu student_id ba shudhu course_id unique noy.

Unique kore identify korte lage tinta mile: (student_id, course_id, semester).

Answer: Composite primary key = (student_id, course_id, semester). grade ekta non-key attribute (eta key er upor depend kore).

Solved Problem 2 Ekta relation R e attributes {A, B, C} ase. Janano holo AB unique kore identify kore, ar A eka-o unique kore identify kore. Candidate key kon gula?

A eka unique kore → A super key. AB-o super key kintu A bad dile B chole na... ar A eka choley. Tai AB minimal noy (B extra).

Minimal super key = jeta theke kichu bad dile r unique thake na. A theke kichu bad dewa jay na (already single). Tai A i candidate key.

Answer: Candidate key = {A}. AB shudhu ekta super key (minimal noy).

2 · SQL Written + Viva

Silberschatz Ch 3–5 · Query likhar practice koro

SQL = Structured Query Language. Admission e tomake query likhte bola hote pare, ar output bolte bola hote pare. Niche sob clause example soho.

Sample tables (ei gula diye sob example)

Employee
emp_idnamedeptsalary
1RahimCSE50000
2KarimEEE45000
3SadiaCSE60000
4NabilaCSE55000
5TaniaEEE48000

Core clauses

SELECT + WHERE

-- CSE dept er sob employee
SELECT name, salary
FROM Employee
WHERE dept = 'CSE';

Output: Rahim/50000, Sadia/60000, Nabila/55000.

ORDER BY

SELECT name, salary FROM Employee
ORDER BY salary DESC;   -- DESC = boro theke choto

Aggregate functions

COUNT(), SUM(), AVG(), MAX(), MIN()

SELECT AVG(salary) FROM Employee;        -- sob er average
SELECT MAX(salary) FROM Employee WHERE dept='EEE';

GROUP BY + HAVING

Key difference — pakka MCQ
WHERE row filter kore group hobar age. HAVING group filter kore group hobar pore. Aggregate (COUNT, SUM...) diye filter korte HAVING lage, WHERE noy.
-- Prottek dept er average salary, jegula 50000+
SELECT dept, AVG(salary) AS avg_sal
FROM Employee
GROUP BY dept
HAVING AVG(salary) > 50000;

CSE avg = (50000+60000+55000)/3 = 55000 ✓ | EEE avg = (45000+48000)/2 = 46500 ✗. Output: shudhu CSE.

JOINs

Join typeKi dey
INNER JOINDui table er matching row matro
LEFT (OUTER) JOINLeft table er sob + right er matching (na thakle NULL)
RIGHT JOINRight table er sob + left er matching
FULL OUTER JOINDui table er sob row
CROSS JOINCartesian product (m × n row)
SELECT e.name, d.dept_name
FROM Employee e
INNER JOIN Department d ON e.dept = d.dept_code;

Subquery (nested query)

-- Average er beshi salary jara pay
SELECT name, salary FROM Employee
WHERE salary > (SELECT AVG(salary) FROM Employee);

AVG = (50000+45000+60000+55000+48000)/5 = 51600. Output: Sadia(60000), Nabila(55000).

Solved Problem 1 Likho: prottek dept er moddhe sob theke beshi salary jini pan, tar dept ar salary ber koro, jekhane oi max salary 50000 er beshi.
SELECT dept, MAX(salary) AS max_sal
FROM Employee
GROUP BY dept
HAVING MAX(salary) > 50000;

CSE max = 60000 ✓, EEE max = 48000 ✗. Output: CSE / 60000.

Khoyal koro — aggregate (MAX) diye filter, tai HAVING, WHERE noy.

Solved Problem 2 SELECT COUNT(*) ar COUNT(salary) er moddhe difference ki? Jodi ekta row e salary NULL thake?

COUNT(*) sob row gone — NULL soho. COUNT(salary) shudhu jegular salary NULL noy sheigula gone.

5 row, 1 tar salary NULL hole: COUNT(*) = 5, COUNT(salary) = 4.

Aggregate functions (SUM, AVG, COUNT(col)) NULL ke ignore kore — eta common MCQ trap.

Common trap: SQL e NULL = NULL TRUE noy, eta UNKNOWN. NULL check korte IS NULL / IS NOT NULL use korte hoy, = NULL noy.

3 · Relational Algebra

Silberschatz Ch 2/6 · Symbol gula MCQ te ase

Relational algebra holo SQL er theoretical bhitti — symbol diye query lekha. MCQ te symbol ar tar mane jiggesh kore.

OperationSymbolKaj
Selectσ (sigma)Row filter (WHERE er moto)
Projectπ (pi)Column bachai (SELECT col)
UnionDui relation er sob row (duplicate baad)
Set DifferenceR e ache kintu S e nei
Cartesian Product×Sob combination
Renameρ (rho)Relation/attribute notun nam
Natural JoinCommon attribute diye join
IntersectionDui tetei ache
Mone rakho — basic vs derived
6 ta fundamental (basic) operation: σ, π, ∪, −, ×, ρ. Baki gula (∩, ⋈, ÷) eder theke banano jay — tai "derived". Eta MCQ te ase: "Which is NOT a fundamental operation?" → answer hoy join ba intersection.

Example

σ (salary > 50000) (Employee)
   → salary 50000 er beshi jara, sob column

π (name, dept) (Employee)
   → shudhu name ar dept column

π (name) ( σ (dept='CSE') (Employee) )
   → CSE dept er employee der name
Solved Problem 1 Ei SQL ke relational algebra te lekho:
SELECT name FROM Employee WHERE salary > 45000;

Age WHERE (row filter) = σ, tarpor SELECT column (project) = π.

πname ( σsalary > 45000 (Employee) )

Order matters likhte: select (σ) bhitore, project (π) bahire — efficient.

Solved Problem 2 Ekta relation R e 4 ta tuple, S e 3 ta tuple. R × S te koto ta tuple?

Cartesian product = prottek R row er sathe prottek S row. Tuple count = |R| × |S| = 4 × 3 = 12.

Ar column (degree) = R er degree + S er degree (jog hoy).

4 · ER Model (Entity-Relationship)

Silberschatz Ch 6/7 · Diagram + cardinality

ER model diye database design kora hoy — bastob world ke entity ar relationship diye represent kora.

Component gula

ElementDiagram shapeMane
EntityRectangleObject (Student, Course)
AttributeEllipseProperty (name, age)
RelationshipDiamondEntity gular sম্পর্ক (enrolls)
Key attributeUnderlined ellipsePrimary key (roll)
Multivalued attrDouble ellipsephone numbers (ekadhik)
Derived attrDashed ellipseage (DOB theke ber)
Weak entityDouble rectangleNijer key nei, parent lage

Cardinality (mapping) — important

Table e convert korar niyom
M:N relationship ke alada ekta table banate hoy (dui pasher primary key niye composite key). 1:N e "many" pasher table e foreign key boshe. Eta written e ase.
Solved Problem 1 Ekta "Student takes Course" relationship — ek student onek course nite pare, ar ek course onek student nite pare. Eta kon type? Table e koto gula table lagbe?

Dui pasher-i "onek" → Many-to-Many (M:N).

Table: Student, Course, ar ekta junction table Takes(student_id, course_id) — total 3 ta table. Junction table er composite PK = (student_id, course_id), dutoi foreign key.

Solved Problem 2 Weak entity ar strong entity er moddhe parthokko ki?

Strong entity: nijer primary key ache, eka thakte pare.

Weak entity: nijer puro primary key nei. Identify hote hole strong (owner) entity er upor depend kore. Eta "partial key" (discriminator) + owner er key mile identify hoy. Diagram e double rectangle, relationship double diamond.

Example: "Dependent" (employee er poribar) — employee chara identify kora jay na.

5 · Normalization High weight ★

Silberschatz Ch 7/8 · FD + decomposition · MCQ+Written

Normalization = table ke এমনভাবে design kora jate redundancy kome ar anomaly (insert/update/delete problem) na hoy. Ei topic admission e pakka ase.

Functional Dependency (FD) — bhitti

X → Y mane: X jana thakle Y nirdharon hoy. Eg: roll → name (roll diye name pawa jay).

Term gula
Prime attribute: kono candidate key er part. Non-prime: kono candidate key er part na.
Partial dependency: non-prime attribute candidate key er ek angsher upor depend kore.
Transitive dependency: non-prime → non-prime (X→Y→Z, X key).

Normal Forms — step by step

1NF (First Normal Form)

Prottek cell e ekta-i (atomic) value. Multivalued / repeating group thakbe na.

Eg: ek column e "Math, Physics" thakle — eta 1NF bhongo. Alada row korte hobe.

2NF (Second Normal Form)

1NF + kono partial dependency nei. Mane non-prime attribute puro candidate key er upor depend korbe, ek angsher upor noy.

Shudhu composite key thakle 2NF niye chinta korte hoy. Single-attribute key hole automatically 2NF.

3NF (Third Normal Form)

2NF + kono transitive dependency nei. Non-prime attribute onno non-prime attribute er upor depend korbe na.

BCNF (Boyce-Codd Normal Form)

3NF er kothin version. Prottek FD X → Y te X obossoi ekta super key hote hobe. 3NF allow kore jodi Y prime hoy, BCNF kore na.

Mone rakho (MCQ): 1NF → 2NF (partial baad) → 3NF (transitive baad) → BCNF (sob determinant super key). Prottek upor-er ta nicher ta-ke include kore. BCNF holei 3NF, kintu 3NF holei BCNF noy.
Solved Problem 1 — full decomposition Table: R(StudentID, Course, Instructor). FD gula:
StudentID, Course → Instructor
Instructor → Course
Eta kon normal form e ache, ar 2NF/3NF e bhanlে ki hoy?

Candidate key ber kori: (StudentID, Course) sob nirdharon kore → candidate key. Abar Instructor→Course thakay (StudentID, Instructor)-o ekta candidate key.

Prime attributes: StudentID, Course, Instructor (sob-i kono key er part!).

1NF: atomic value, ✓.

2NF: non-prime attribute nei (sob prime) → partial dependency er prosno-i othe na → 2NF ✓.

3NF: prottek FD te hoy LHS super key, noy RHS prime. Instructor→Course e Course prime ✓ → 3NF ✓.

BCNF: Instructor→Course e Instructor super key NOY → BCNF bhongo.

BCNF decomposition: R1(Instructor, Course), R2(StudentID, Instructor). Ekhon prottek FD er LHS super key.

Solved Problem 2 — anomaly chinha Student(roll, name, dept, dept_head) e roll→name,dept ar dept→dept_head. Eta kon NF? Ki anomaly hobe?

Candidate key = roll (single). Tai 2NF ✓ (partial dependency er proshno nei)।

Kintu roll → dept → dept_head — eta transitive dependency (dept_head non-prime depend kore dept non-prime er upor)। Tai 3NF bhongo, table ekhono 2NF te ache.

Anomaly:

  • Update: ek dept er head bodlale onek row update korte hobe.
  • Insert: notun dept (student na thakle) add kora jay na.
  • Delete: ses student delete korle dept_head info hariye jay.

3NF decomposition: Student(roll, name, dept) + Dept(dept, dept_head).

Solved Problem 3 — quick check Ekta table R(A,B,C,D), candidate key AB, FD: AB→C, AB→D, C→D. Highest normal form ki?

Prime: A, B. Non-prime: C, D.

2NF: C,D ki AB er angsher upor depend kore? AB→C,D — puro key er upor, partial nei → 2NF ✓.

3NF: C→D dekho — C super key noy, ar D prime-o noy → transitive dependency. 3NF bhongo.

Answer: Highest NF = 2NF.

6 · Transactions & Concurrency

Silberschatz Ch 17–18 · ACID + serializability

Transaction = ek ba ekadhik operation er logical unit ja "sob-i hobe noile kichu-i hobe na" niyom mene chole.

ACID Properties — pakka MCQ/viva

PropertyMane
AtomicityPura transaction hobe, noile kichui na (all-or-nothing)
ConsistencyTransaction er age-pore database valid state e thakbe
IsolationConcurrent transaction eke onnoke disturb korbe na
DurabilityCommit hole data permanent — power gele-o thakbe

Transaction states

Active → Partially committed → Committed | (problem hole) → Failed → Aborted

Schedule & Serializability

Concurrency problems (anomalies)

Locking — 2PL

Two-Phase Locking (2PL): dui phase — Growing (shudhu lock newa) ar Shrinking (shudhu lock chhara)। Ekbar lock chharle r notun lock newa jabe na. 2PL conflict-serializability nishchit kore.

Solved Problem 1 ATM theke 500 taka tola — balance check, taka deya, balance update. Majhpথে power chole gelo taka deyar por kintu update er age. Kon ACID property eta thik kore?

Operation gular ek angsho holo (taka berolo) kintu baki angsho holo na (balance update holo na) — eta partial execution.

Atomicity eta thik kore: hoy puro transaction hobe, noile rollback kore kichui hobe na. Tai taka-o berobe na, ba berole abar fire ashbe.

Solved Problem 2 Conflict serializable kina test korte ki use kora hoy, ar condition ki?

Precedence graph (serialization graph) banano hoy — node = transaction, edge = conflict order (read-write/write-write same data).

Condition: graph e cycle na thakle schedule ti conflict serializable. Cycle thakle noy.

7 · MCQ Practice GATE / CUET style

Option e click koro — sathe sathe answer + explanation

Eigula bhalo kore bujhe nao। Concept clear thakle MCQ e bhul hobe na।

Score nije track koro — kon topic e bhul hoy sheta abar oi tab e fire giye poro।


DBMS note shesh। Porer ta — Operating System (Scheduling + Memory + Deadlock) banai debo bolle। 💪