Creating tables & generating code in ChartDB
Ankur Singh
Posted on November 3, 2024
Introduction
Welcome š to this blog. Are you working with databases with complex schema and you are stuck in visualizing the entire database in one view so that your task will be easier then we got you covered!!! We are introducing ChartDB to visualize your DB which is a Free and open-source, database design editor. Open source & no login required, yep you heard it correctly. You can also generate the scheme code for complex tables.
SQL Tables
Suppose we in our organization work in a database containing the stores' data. In this scenario we have three tables named Product, Store & Customer.
The schema of these tables is as follows:
Store
-----
store_id INT PRIMARY KEY
area_sq DECIMAL(10,2)
city VARCHAR(100)
province VARCHAR(100)
Product
-------
product_id INT PRIMARY KEY
store INT FOREIGN KEY REFERENCES Store(store_id) ON DELETE CASCADE
price DECIMAL(10,2)
description TEXT
name VARCHAR(100)
Customer
--------
customer_id INT PRIMARY KEY
product INT FOREIGN KEY REFERENCES Product(product_id) ON DELETE SET NULL
store INT FOREIGN KEY REFERENCES Store(store_id) ON DELETE SET NULL
name VARCHAR(100)
age INT
But in this case, we have only three tables but it can vary based on the complexity of the projects we are working on. We can have a good number of tables as well. So we can understand that visualizing this many tables can be a nightmare. But using ChartDB we can easily visualize the tables.
Using ChartDB to visualize the tables
First thing first, visit the ChartDB app link here. Then you can see this type of UI:
Then we will create the first table named Store
Our table will look like something like that:
Some features of chartDB are as follows:
- Variety of data type
- Adding indexes to the tables
- Adding comments in the tables
Here we go
Here we have all the three tables, now the only thing remaining is to create the relation between them:
This is the completed version of the visualization of the tables with their relation as well.
Save the image
You can also generate the code as well.
š You nailed it
You have now learned how to use ChartDB in personal as well as for the business purpose.
Thank you for reading! If you enjoyed this content, feel free to connect to me:
š§ Email: ankursingh91002@gmail.com
š LinkedIn: Ankur Singh
š Twitter: @ankur_136
Let's connect and create something great together!
Posted on November 3, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.