Part 2 — Data Models, Languages & Relational Algebra
CLO2 · high value. The DDL/DCL/DML/TCL table is pure recall; the relational-algebra parts reward drawing the resultant table carefully.
Q3smallDefine ‘database language’ and fill the DDL / DCL / DML / TCL table (≥3 commands each). (1 + 2)
Relational algebra — the operator toolkit
σ π ∪ − × ρ6 basics: Select (rows) · Project (columns) · Union · Difference · Cartesian product · Rename. Joins are × + σ.
Q4 — Employee & Department
The two given relations:
| EID | EmpName | DeptID |
|---|---|---|
| 1 | Rahim | 10 |
| 2 | Karima | 20 |
| 3 | Sumon | 10 |
| 4 | Nila | 30 |
| DeptID | DeptName | Location |
|---|---|---|
| 10 | HR | Dhaka |
| 20 | Finance | Chattogram |
| 40 | IT | Sylhet |
Spot the mismatch before you start. Employee depts = {10, 20, 30}; Department depts = {10, 20, 40}. So Nila (30) has no department and IT (40) has no employee — exactly what parts (b) and (c) test.
Q4(a)Write the relational algebra for the Cartesian product and draw the complete table. (3)
Q4(b)Write the join that returns all information for employees who belong to a department. Give the resultant table. (2)
Q4(c)What is the output of Employee ⟕ Department, and what information does it give? (3)
Q4(d)Write the join to find all employees who live in Dhaka. Give the resultant table. (3)
Join types — one picture to keep them straight
Filled region = rows kept. Left circle = Employee, right circle = Department.
Operator summary
| Symbol | Name | Does |
|---|---|---|
| σ | Selection | Rows matching a predicate |
| π | Projection | Chosen columns; removes duplicates |
| × | Cartesian product | All row pairs of two relations |
| ∪ · − · ∩ | Set ops | Union · difference · intersection |
| ⋈ | Natural join | × then match same-named attributes |
| ⟕ ⟖ ⟗ | Outer joins | Keep unmatched left / right / both as NULL |
| ρ | Rename | Rename a relation / its attributes |
Want to try these live on other data? Open the RA Playground →
Next: Part 3 — ER Diagram →