SpringBoot actual e-business project mall (30K + STAR) address: github.com/macrozheng/…

Abstract

A good database design tool can help us think and improve our design efficiency. I have been using PowerDesigner for a long time. Recently, I found that Navicat’s database design function is also very good. The interface is simple and easy to use.

Navicat

Navicat is a fast and reliable database management tool designed to simplify database management and reduce system administration costs. It is designed to meet the needs of database administrators, developers, and small and medium-sized enterprises. Navicat is built with an intuitive graphical user interface that allows you to create, organize, access, and share information in a secure and simple way.

Note: this tutorial Navicat12 version, the download address: www.navicat.com.cn/download/na…

Database design

Let’s talk about how to use Navicat to design the database, taking mall project’s permission management module as an example.

Open the model

First we need to open Navicat’s database design function, which is in the toolbar under the Model button, directly open.

The new table

  • Through the toolbartableButton to create a new table;

  • After the creation is complete, double-clickThe design table“, and then add the corresponding field, here is a new oneums_adminTable;

Establish foreign key relationships

If our table does not have foreign keys, we will not be able to clarify the relationship between tables as more and more tables and relationships become more and more complex. Therefore, we need to mark the relationship between tables through foreign keys during design.

  • Let’s create two more tablesums_roleandums_admin_role_relationUsed to demonstrate the establishment of many-to-many relationships and through the toolbarA foreign keyButton to establish a foreign key;

  • Click on theA foreign keyClick the field to create a foreign key directly after the buttonadmin_idAnd then you’ll find one moreSmall wire;

  • Double-click theSmall wireEdit the foreign key and modify the reference tableums_admin, the reference field isid;

  • After editing, there will be a line representing the foreign key relationship;

  • And then you can put the wholemallProject authority management module table are set up to practice, the following is the effect of the completion of the establishment;

  • How about if you think the layout is bad, you can click on the toolbarAutomatic layout adjustment function, is not a very intimate function!

Export SQL

We generally design the database through foreign keys to establish relationships, but in the database often do not use foreign keys, usually through logic to associate, so when we export SQL need to set to exclude key generation.

  • Export SQL function under tools menu;

  • You need to export in theseniorTo generate the exception key, click OK to successfully export the SQL statement.

Reverse engineering

Here is another way to view the database design through Navicat.

  • First we need a SQL file with foreign key relationship, here I have generated, download address: github.com/macrozheng/…

  • Then import the SQL file into the database, in this case the PD-test database;

  • Then through reverse engineering to generate database design from the database, this function is under the tools directory;

  • Then select the database you want to importpd-test;

  • After the import is successful, you can see the complete relational database design, and you can change the table position as you like.

conclusion

In general, Navicat’s database design function is quite good, simple and easy to use, the interface is also very beautiful. Designing a database is just a feature in PowerDesigner, which is too heavy to use. Navicat’s database design feature is lighter!

The public,

Mall project full set of learning tutorials serialized, attention to the public number the first time access.