Relationships connect your entities and express how rows relate. Schemity draws them in crow’s foot notation, the notation most software engineers read fastest.

Creating a relationship

Draw a relationship between two entities and Schemity creates the foreign key field on the child entity and the connector between them. In the relation dialog you set:

  • Relation type - 1:N, 1:1, or N:N.
  • On delete and On update - the referential actions: CASCADE, SET NULL, RESTRICT, NO ACTION, or SET DEFAULT.

Reading crow’s foot notation

The symbols at each end show cardinality and optionality:

  • A single bar means “one”.
  • The crow’s foot (three prongs) means “many”.
  • A circle means “optional” - shown at the child end when the foreign key field is nullable.

So a connector with a bar on the parent and a crow’s foot on the child reads as one-to-many.

1:N vs N:N relationships

Understanding 1:N vs N:N relationships is the key modeling decision:

  • One-to-many (1:N) - one parent row relates to many child rows. A user has many orders. This is a direct foreign key.
  • One-to-one (1:1) - at most one row on each side.
  • Many-to-many (N:N) - rows on both sides relate to many on the other. Students and courses. A relational database cannot store this directly; it needs a junction entity - see Junction Tables.

Self-referencing relationships

An entity can relate to itself - an employees.manager_id pointing back at employees.id. Draw the relationship from the entity to its own key.

Copy and paste with foreign keys

When you copy or duplicate entities, Schemity is smart about foreign keys: relationships to entities you also copied are preserved with remapped names, while relationships to entities left behind are dropped and the field becomes a plain field.

Routing

To control how a connector is drawn around other entities, add Custom Waypoints.

Next

Add finer rules with Check Constraints & Composite Unique.