prd

Peter's Relational Diagrams

Category: SQL

Introduction🔗

I like to organize my thoughts on paper. Especcially when I am working on a new project or prototype. IMHO it is better to take a 30 minute timeout to make a good database design then to run many migration scripts during the first sprint.

Over time, I kinda developed a paper tool/method that helps me create a good struture in a short time.

The method is simple🔗

As we are modeling the database tables, we can simplify the workload for our brain if;

  • focus on the relations between the tables. The detail fields (name, age, gender, phonenumber, price, ..) are easy to describe later.
  • forget the naming of the fields. This is something that could be rather straight forward. A one-to-one relationship between table 'Person' and 'Employee', can be standardized to 'person_id' or 'employee_id'. Whatevah...

Recipy🔗

1 Take a lined piece of paper (e.g. use a plain note book) 2 To the left margin, make a column approx 5 cm wide. 3 Take the table names that you want to use and write them in th first colomn. 4 If there is a relation for that table (on one or more fields, draw a line in the 'next' column

  • for one-to-one relations, use a ----- line as a relationship indicator.
  • for one-to-many relations, use a *-----> line as a relationship indicator. 5 Draw a vertical line next to the freshly created relationship indicators, thus creating a new 'next' column 6 goto 3 until you are done.

An example🔗

Here is an example that I created some time ago. I hope that you can read my scribbles.

model sketch

Eventually that project did not get in to the [incuberator](todo add link), so I guess that I can share how the model turned out.

model.svg

WTF?🔗

Of course, YMMV, but I like it. I do not know if this is a official way of working, but if I may choose a buzzword I would name it PRD, Peter's Relationship diagram