DEV Community

loading...
Cover image for Data Modeling Tool

Data Modeling Tool

dev0928
Full stack developer
・2 min read

Recently, I was looking for tools to quickly come up with an ERD (Entity-Relationship Diagram) for one of the client engagements. I wanted it to be something simple but aesthetically pleasing as it was an early stage of the project. I came across an online tool called dbdiagram.io. This tool helped in coming up with a nice pictorial representation of the data model relatively quickly.

Features supported by the tool:

  • Primary key representation
  • Foreign key representation along with one-to-one, one-to-many, many-to-one relationships
  • Support for representing fixed number of values a column can hold through Enum tables
  • Support for default values and unique column representation.
  • Ability to export created data models into PNG or PDF formats. Also, one can export SQL of the data model for PostgreSQL, SQL Server, and MySQL (account sign-up required to utilize these features)
  • Ability to import SQL to generate data model

How does it work?

  • Visit dbdiagram.io and come up with a desired data model structure like below. This tool generates data model as soon the entered structure is valid.
// Creating tables
Table department as d {
  department_id int [pk, increment] // auto-increment
  department_name varchar [not null, unique]
  created_at datetime [default: `now()`]
}

// Enum for 'employee' table below
Enum employee_status {
  active
  retired
  alumini [note: 'moved on to other career prospects'] // add column note
}

Table employee as e {
  employee_id int [pk, increment] // auto-increment
  employee_name varchar
  department_id int [ref: > d.department_id]
  status employee_status
  created_at datetime [default: `now()`]
}

Table employee_sales as es {
  employee_id int [ref: > e.employee_id] 
  sales_date datetime 
  sales_amount float
  Indexes {
    (employee_id, sales_date) [pk]
  }
 }
Enter fullscreen mode Exit fullscreen mode

Example output is shown below

Alt Text

Discussion (0)