Generating ERDs from DBT Projects: A Code-Driven Approach

Vaibhav Chopda
6 min readJul 3, 2024

Introduction

Many users of dbt are well aware of the challenges involved in managing Entity-Relationship Diagrams (ERDs) within the platform. There is no straightforward way to handle our project ERD as code. Typically, ERDs are maintained in tools like Lucidchart or Visio, which become increasingly difficult to manage over time. Often, you might not even realize that these diagrams no longer serve their intended purpose. This was precisely the issue I encountered with my dbt project

DBT Jaffle Shop ERD

Understanding ERDs and Their Importance

Entity-Relationship Diagrams (ERDs) are essential tools for both developers and business users. These diagrams elucidate the complex relationships within data, illustrating connections such as those between customers, accounts, and subscriptions. ERDs also specify the types of relationships, whether one-to-one or one-to-many, which is vital for accurate database design and data integrity. By providing a clear visual representation of these connections, ERDs enhance communication among stakeholders and ensure a shared understanding of the database structure.

The Challenges of Managing ERDs in DBT

DBT has revolutionized data modeling by eliminating the need for multiple…

--

--