BEGINNER · 12 MIN · FREE LESSON
Relational model & keys
Explore relational model & keys through a visual, step-by-step model.
Loading interactive lesson…
BEGINNER · 12 MIN · FREE LESSON
Explore relational model & keys through a visual, step-by-step model.
Loading interactive lesson…
Small customers/orders relations. Customer and order IDs are primary keys; nullable customerId is a foreign key. SQL equality never matches NULL. Duplicates and orphan keys are reported; enforced constraints reject the example relation before query execution. JOIN outputs preserve bag multiplicity. Query-order mode applies WHERE before grouping, then HAVING, ORDER and LIMIT.
Loading architecture diagram…
Identify entities, keys and the one-to-many relationship before evaluating a query.
C customers, O orders and G groups. This is an explicit logical query evaluator, not PostgreSQL optimizer order or a claim about indexed/hash joins.
Join comparisons, seed 42. Plotted sample sizes respect each lesson’s explicit input limits.
Keyboard: Space play/pause · ←/→ step · R restart · 1–5 speed. Reduced motion disables transitions.
A customer can place many orders; a nullable order relationship still cannot point at a customer who does not exist.
Inspect the relation or dependency state, then follow each validated decision. Use presets first; custom JSON preserves the displayed schema and bounds.
Distinguish rows, columns, domains, primary keys, candidate keys and foreign keys. The example enforces Customer.id and Order.id uniqueness and validates every non-null Order.customerId. NULL represents an optional relationship; it does not equal a missing customer.
Add a duplicate ID and a non-null orphan, then compare enabled constraints with the explicit unsafe experiment. NULL foreign keys remain allowed. Predict the next constraint, match or dependency decision before advancing.
The player names its measured operation and reports the core model cost. Separate fixture construction and index maintenance from the operation being measured; the displayed assumptions name each bound. These are teaching algorithms, not real database latency benchmarks.
Four language references implement the core mechanism over validated example data. The reference containers illustrate the declared model scope; real persistence, distributed coordination, recovery and provider limits require their own implementation. The interactive prose identifies baseline references or additional player experiments explicitly.
For transactional entities, stable identities and referential integrity across one-to-many relationships.
Database constraints are the concurrency-safe authority. A prior application SELECT cannot enforce uniqueness under a race. Candidate keys are minimal unique determinants; a surrogate primary key does not remove business uniqueness requirements.
Explain a valid result, name the governing invariant and distinguish logical semantics from a physical implementation.
MAKE IT STICK
Progress saves on this device and merges with your account after sign-in.
0 / 5000 · Saved on this device; synced when signed in.