Relational Data Design and Drizzle

Ben Prothe - - 1 min read

Series: Final Project Rebuild

So, remember this where I talk picking a robust ORM solution? Well, I’ve begun to draw out my entity relationship diagram (shoutout to Lucidchart) and I am working on the problem of keeping my tables from getting “too wide”– one of the fundamental weaknesses of typical ORMs. Here are a few of the features of Drizzle that are going to save me:

  1. To create many-to-many relationships you actually create a proper join table where values other than foreign keys can live. I will need some of the join tables to contain information unique to each junction. I wouldn’t have that kind of granular control over the join table in a regular ORM. The table would be abstracted.
  2. I can use Drizzle’s query and join methods to create an efficient SQL query, without worrying about over fetching data. Here’s more about that.
  3. If the function calls get out of hand, Drizzle has a “magic SQL” operator that will allow me to write a regular ol’ SQL queries.

So far this has been a good design choice.