Forward Engineering: PDM ---> in SQL or database projects, we often need to generate SQL scripts based on PDM and execute them together in the database. If there are many tables in PDM, it will take a lot of time for us to build one by one. We can also directly generate PDM to the database as needed.
Reverse Engineering: SQL or database ---> PDM sometimes we need to generate a PDM Diagram Based on the SQL script, or generate the latest information of the database to PDM.
The following sections describe one by one:
1. PDM generation SQL:
1. Database --- "database generation or Ctrl + G shortcut to open the generate dialog box. After making the following settings, click OK to generate an SQL script.
General labels:
Directory: directory for saving scripts generated
File Name: SQL Script Name
Generation type: generate in two ways:
Script generation: generate the script (Here we choose to generate the script)
Direct Generation: directly generated to the database
One file only: generate a script file (selected by default)
Check model: Check the model (generally, if you do not check the model, an error is reported when you check the model)
Automatic archive: generate an SQL statement and generate an APM Statement at the same time (usually not selected)
Options label:
The user here is usually removed, because the user is generally generated by the DBA, and we do not need to create it here.
Drop table should also be removed; otherwise, there will be drop statements in the script. If the database does not have these tables, an error will be reported.
Selection label:
Here, we can select the PDM to be converted and the objects in PDM to generate SQL.
Preview label:
You can preview the script information to be generated.
Ii. PDM is directly generated to the database:
1. First configure database connection --- configure connections and click Add Data Source
2. Select a System Data Source
3. Select the database driver
4. Complete Data Source Creation
5. In the displayed configuration dialog box, enter the Custom Data Source Name, service name, and user name.
6. Click test connection to perform the test. The test is successful. OK.
7. After the database connection is configured, we can generate it to the database, database --- "database generation
Select Direct Generation (directly generated to the database) and select Edit generation script to edit and modify the script before generation.
8. connect to a data source (select the test data source we created above) and enter the user name and password.
9. The execution dialog box is displayed. You can edit the SQL statement. If you do not need to modify the SQL statement, run it directly. At this point, PDM is successfully generated to the database.
Iii. Reverse Engineering:
1. File --- reverse engineer --- Database