About this article
In this article, you use LucidChart to generate the Structured Query Language (SQL) commands for your database.
This post is the fifth on a series exploring the subject of relational databases for the full-stack developer.
For quick access, here is the list of the articles on the topic:
- Introduction to Relational Databases
- Database Design: Entities, Attributes, and Relationships
- Database Design: Entity-Relationship Diagrams
- Database Design: Normalization
- Database Design: Entity-Relationship Diagram to Structured Query Language (this article)
- Deploying PostgreSQL for development and testing
- Structured Query Language Cheat Sheet
- Working with databases from Python
Introduction
In the last article, we applied normalization techniques to our database to obtain a design meeting the third normal form (3NF). We also implemented those design changes in our entity-relationship diagram in LucidChart.
In this article, you will generate the SQL commands for implementing your database in PostgreSQL, directly from LucidChart. This article is a short one since you already completed most of the hard work by creating a normalized database design. Let’s get to it.
Open your entity-relationship diagram
Go to LucidChart an open the document containing the ERD you completed in the last article.
Export to SQL
Look for the Entity Relationship section in the toolbox on the left of the screen and click on Export.
An Export to SQL window will open.
Select a SQL syntax. In your case, you will be implementing this database in PostgreSQL in the following articles, so select PostgreSQL.
The resulting SQL should look like this:
Click on Copy to Clipboard and paste in a text editor. Save the file. You will be using it in the next article.
That’s it! Click on Done to close the Export to SQL window.
Conclusion
In this article, you learned how to generate the SQL commands for creating all your database tables, with keys and constraints, with a few clicks using LucidChart.
In the next article, you will deploy an instance of PostgreSQL and create your database in it.
References
You may also like: