0 · Exam Mapcourse + brief
| Final Exam | 50% | weekly quizzes | 21% |
| SQL tasks | 6% | Early feedback quiz | 3% |
| Conceptual Model Assignment | 10% | SQL Online Quiz | 10% |
official rulePaper-based exam, 2 hours, closed book. ISYS2120 current Canvas Assessment overview; 2026 intro slides
Retrieval order: define the object → state the formal rule → apply it to the shown rows → name the retained/rejected result → test one boundary case. A plausible diagram or query is incomplete until its meaning and result are checkable.
1 · Database Corefoundations
| Term | Recite |
|---|---|
| Data | recordable facts that matter and must persist |
| Database | persistent organisational data |
| DBMS | software coordinating storage, metadata, queries, integrity, sharing, recovery and security |
| Metadata | structure, origin and obligations describing data |
| Catalogue | database-held names, datatypes and constraints |
A relation has uniformly structured tuples over named attributes and domains. Schema is the stable description; instance is the current contents. Every update changes the instance; every valid instance must fit the schema. Mathematical relations have no duplicate rows and no meaningful row order.
Recall → Logical independence protects user views; physical independence protects the conceptual design from storage changes.
2 · Keys & Integrityfoundations
candidate-key testProposed columns distinguish every row in every permitted state, not merely the sample; one counterexample rejects the claim.
| Domain/type | permitted value kind |
| PRIMARY KEY | selected identity: unique and present |
| FOREIGN KEY | non-NULL value matches a target key |
4 · ER Constraint DecoderER modelling
Start from requirements. An entity type groups distinguishable objects; an attribute describes an entity or relationship; a relationship type records a fact among roles. Ask whether each noun needs independent identity and retained facts.
| Composite attribute | has meaningful parts |
| Multivalued attribute | one entity may have several values |
| Relationship attribute | depends on the participant combination |
| Question | Constraint | Meaning |
|---|---|---|
| How many at most? | maximum cardinality / key constraint | limits counterparts |
| Must every one participate? | minimum / total participation | at least one relationship instance |
| Who does what? | role name | disambiguates recursive participation |
Say every mark in plain domain language. Then narrate one valid and one invalid population. If requirements are silent, state the assumption instead of smuggling in a business rule.
Weak entity
A weak entity's identity combines an owner's key with a local discriminator. Few attributes or low importance do not make it weak; owner-dependent identity does.
A key is minimal: remove a necessary component and it no longer distinguishes every entity.
Harder structures
| Recursive | same entity type plays distinct named roles |
| ISA | choose subtype constraints deliberately; preserve inheritance |
| Ternary / aggregation | keep the combined fact when binary links would lose or invent combinations |
5 · SQL: Build the Resultquery foundations
| Clause / idea | Job | Diagnostic |
|---|---|---|
| SELECT | target columns / expressions | only requested output? |
| FROM | source relations | all needed, no extras? |
| JOIN / ON | connect matching facts | missing predicate multiplies rows |
| WHERE | keep rows whose predicate is TRUE | boundary and NULL case? |
| GROUP BY | partition surviving rows | right population? |
| HAVING | filter completed groups | aggregate belongs here |
| ORDER BY | sort result | membership unchanged |
fast query planOUTPUT columns → SOURCE relations → CONNECTIONS → FILTERS → predicted smallest result.
NULL is unknown
Comparisons with NULL do not become TRUE; use IS NULL, not = NULL. Keep missing values explicit when predicting filters and aggregates. SQL normally preserves duplicate result rows; DISTINCT removes duplicates only when uniqueness is required.
Trap → DISTINCT is not a repair for a faulty join. First explain why repeated rows exist; then decide whether the requested projected values should be unique.
5b · SQL Contrast Deckquery foundations
| Pair | Difference to recite |
|---|---|
| projection / selection | output attributes versus retained rows |
| equi-join / natural join | explicit equality keeps both match columns; natural matches every same-named column and keeps one copy |
| alias / stored name | temporary scope name versus schema object name |
| duplicate rows / repeated facts | same projection need not mean the source fact is duplicated |
| membership / order | WHERE decides inclusion; ORDER BY changes presentation |
| expression / stored value | target expression computes output without adding a base column |
6 · Joins, Groups, TestsSQL + advanced
| If the request says… | Use / protect |
|---|---|
| only matching facts | inner / theta join with explicit condition |
| every left row, even none | LEFT JOIN; unmatched right attributes become NULL |
| one table in two roles | aliases; qualify attributes |
| summary per value | GROUP BY that value |
| filter raw rows | WHERE before grouping |
| filter summaries | HAVING after grouping |
counting retained left rowsStart from every left entity → LEFT JOIN matches → GROUP BY left key → COUNT(non-NULL right key). COUNT(*) counts the joined row, including an unmatched NULL-extended row.
Diagnostic data
| ordinary match | base meaning |
| unmatched row | inner vs outer join |
| repeated projected value | bag vs DISTINCT |
| NULL | three-valued filter / aggregate |
| boundary value | > versus ≥ |
| empty group | retention and count choice |
Predict intermediate rows by hand. The first stage where prediction and result diverge identifies the faulty clause. An accidental Cartesian product pairs every row from one source with every row from the other and can make credible-looking but inflated summaries.
Explain → State why every returned row satisfies the request and why one boundary row is excluded. A query that runs is not yet evidence that the meaning is right.
6b · Grouping Logicadvanced SQL
logical populationFROM/JOIN creates candidates → WHERE removes rows → GROUP BY partitions survivors → aggregates summarise each group → HAVING removes groups → SELECT forms output.
| COUNT(*) | counts retained joined rows |
| COUNT(column) | ignores NULL in that column |
| Unmatched left row | one NULL-extended row survives a LEFT JOIN |
| Empty-match count | count a right-side key to obtain zero |
7 · DDL as Contractschema design
| DDL device | Promise | Failing probe |
|---|---|---|
| Datatype | column value kind | incompatible value |
| NOT NULL | value present | missing mandatory field |
| PRIMARY KEY | unique, non-NULL identity | duplicate full key |
| UNIQUE | distinct non-NULL value/combination | repeated candidate value |
| FOREIGN KEY | matching referenced key | dangling non-NULL reference |
| CHECK | row satisfies Boolean rule | boundary-breaking value |
SQL permits multiple NULLs in a UNIQUE column unless it is also NOT NULL. A composite primary key constrains the combination; individual components may repeat. Referential actions are domain policies: restriction blocks a change; cascading propagates it; setting NULL needs an optional reference. Historical retention may rule out automatic deletion.
answer scaffoldRequirement → declared type/constraint → attempted invalid row → named rejection → resulting stored table.
8 · ER → Relationsschema mapping
| Conceptual pattern | Relational decision |
|---|---|
| strong entity | relation; entity key becomes relation key |
| simple attribute | column |
| composite attribute | flatten into component columns |
| multivalued attribute | separate relation |
| 1:M relationship | one-side key migrates as FK to many side |
| M:N relationship | associative relation with both FKs; relationship attributes live there |
| weak entity | owner key + discriminator form identity |
| total participation | use NOT NULL where the mapping can enforce it |
9 · Relational Algebraalgebra + SQL
| Operator | Effect | Check |
|---|---|---|
| σp(R) | selection: rows satisfying p | heading preserved |
| πA(R) | projection: named attributes | duplicates removed under set semantics |
| ρ(R) | rename relation/attributes | scope unambiguous; enables self-join |
| R × S | all tuple combinations | usually constrain into join |
| R ⋈p S | pairs satisfying p | meaningful match |
| ∪, ∩, − | set union/intersection/difference | union-compatible headings/domains |
| R ÷ S | candidates paired with every S tuple | complete divisor audited |
translation warningSQL SELECT ≈ algebraic projection π; SQL WHERE ≈ algebraic selection σ.
Push selection before expensive combinations when equivalent. For set operators, matching column counts are insufficient: corresponding attributes need compatible domains and meanings. Equivalence means the same relation for every valid database state under the stated set/bag and NULL semantics, not agreement on one convenient dataset.
10 · “Every” / Divisionadvanced SQL
double negationSELECT DISTINCT c.id FROM Candidate c
WHERE NOT EXISTS (
SELECT 1 FROM Required r
WHERE NOT EXISTS (
SELECT 1 FROM Fact f
WHERE f.id=c.id AND f.item=r.item));
- Write the complete divisor / required list.
- For each candidate, tick every required pairing.
- One missing pair removes the candidate.
- Extra pairings do not disqualify it.
- Preserve both correlations; dropping one can reverse the meaning or test a global condition.