Skip to content
>devspeak
← glossary
level 4Databases

Relation

also: relations, relationship, relationships, one-to-many, many-to-many

A connection between two kinds of data, like "each customer can have many orders" or "each order belongs to one customer".

a bit more technical

A link between tables, usually implemented with foreign keys: one-to-one, one-to-many (a user has many posts), or many-to-many (through a linking table). ORMs call these "relations". In formal database theory, "relation" also means a table itself.

picture it

A family tree. Each line says how two people connect: parent and child, siblings, spouses. The people are the data. The lines are the relations.

why it matters

How data connects decides which features are easy. "Can a booking have more than one guest?" is a relation question. Getting it wrong early forces painful changes to live data later.

what your agent might say
agent
Right now Recipe has a one-to-many relation with Tag, so each tag can only belong to one recipe. I'd change it to many-to-many.
how you might use it
you → your agent
Before adding team accounts, explain the relations between users, teams and projects, including whether a user can belong to more than one team.
common mistake

Assuming the app just knows two pieces of data belong together. The connection has to be designed and stored, usually as a foreign key.

builds on