Practice Discrete Math

Relations / Databases And State

Least You Need to Know: Relations in Databases and State Machines

Relations are not only abstract sets of ordered pairs. They appear in foreign-key links, join tables, dependency graphs, and state-transition systems used all over software engineering.

The least you need to know

Key notation

R ⊆ A × B a relation from A to B
(state, input) ↦ next_state deterministic transition function
join table table storing many-to-many links

Tiny worked example

  • Many orders can belong to one customer, so the order-to-customer link is many-to-one.
  • A course-enrollment table can connect many students to many courses, which is many-to-many.
  • A state machine transition relation records which next states are allowed from each current state and input.

Common mistakes

How to recognize this kind of problem

Start practice