Skip to content

1. Define your expectations

What do you expect your data to look like? Start by writing down your answer in plain sentences. The goal is to get an idea of the connections and constraints, not to write a detailed specifiation.

Below questions can serve as inspiration:

  • What is already enforced by constraints and foreign keys?
  • What type of mapping do I expect between two tables? One-to-one, One-to-many or Many-to-many?
  • Can some columns only be filled or unfilled in combination?
  • Do the tables referenced by foreign keys have to share something like belonging to the same project/user/organization?
  • Does one row require or imply the existence of other rows?
  • Can this column only have specific values or be in a certain range?
  • Does this column have to be unique across some dimension not covered by the primary key?
  • Should this nullable column actually never be null?
  • What statement would be bad, if it were true for your database?

Continue to the next step, converting your expectations to code, when you are happy with your list of expectations.