After PDM is completed, it will eventually be converted into a database entity.
1. Check whether the DBMS set by powerdesigner is correct, that is, whether it is the database type we want to generate. Here I use sqlserver2000:
Powerdesigner-> database-> change the current DBMS and select your database type.
2. Configure the connection between powerdesigner and the data source
Powerdesigner-> database-> Configure connection-> User DSN (or system DSN)-> select and add your data source
3. Connection
Powerdesigner-> database-> connection-> set the DSN you just created.
OK. After the connection is set, we can generate an SQL statement for PDM.
4. Database generation
Powerdesigner-> database-> Generate database-> Configure (by default) and select OK.
Everyone knows how to execute the SQL script statement. Put it in the SQL query analyzer.
Powerdesigner reverse engineering generates PDM from existing database
In the data modeling process, we establish a conceptual data model, generate a physical data model through a forward project, generate a database creation script, and finally generate a relational database from the physical data model. Now, in turn, uses reverse engineering to generate physical data models for relational databases.
Advantages:
If the lost data model or database model is inconsistent with the existing database, you can use this method to generate a model for the in-use database.
Disadvantages:
In the restored model, there may be no Chinese comments and no ing Relationship Between Foreign keys (fields and indexes are missing)
Prerequisites:
1. Make sure that the database for which the model is to be generated is up-to-date and can be used
2. Install the powerdesigner software.
Procedure:
1. Create an ODBC Data Source
1. Open the system ODBC data source and choose "control panel -- Management Tools -- Data Source (ODBC)
2. Select system DSN and click Add. The following interface is displayed. Select the driver that matches the database.
3. Click "finish" to bring up the data source name (custom) and select the database you want to connect to, as shown in
4. After you select OK, the data source is successfully created. You can double-click the data source name to perform a connection test, as shown in
5. Now the data source has been created. Of course, you do not need to create the data source here. You can also create the data source in powerdesigner. The creation method is
Select database-> Configure connections to go to System
DSN tag, click Add, select database type DB2, and click Finish. The output is as follows: Enter datasource
Name "pdmtest"; enter servername "Database". The configuration is complete. As follows:
Ii. Reverse generation in powerdesigner
1. Open the powerdesigner tool, create a PDM file, and select the database type "IBM DB2 UDB 8.x" that matches the file.
Common server ". Create method: Right-click workspace ----> New ------> physical in the left-side navigation pane.
Data nodel: select the data type you want in the DBMS. After selecting the data type, click OK to create a new workspace.
2. Select reverse engineer database under the database menu. The database reverse dialog box is displayed.
In the engineering dialog box, select using an ODBC data source and select ODBC Data Source "s2ms", as shown in:
3. Click "OK" to display all tables, views, and users in the database (select the users of the database ). Select as needed and convert to PDM. The figure below shows
4. Click OK to generate the model.
3. Generate a model using scripts
If you have not only a database that is being used, but you have a script for creating a database, you're lucky! Because the model generated by A. SQL script does not have the disadvantages of using a database, the specific operation is as follows:
Ii. Generate PDM through SQL script Reverse Engineering
1. Database SQL script file crebas. SQL. The following is a script instance:
/* ===================================================== ======================================= */
/* Database Name: physicaldatamodel_1 */
/* DBMS name: Oracle version 9i */
/* Created on: 10:49:08 */
/* ===================================================== ======================================= */
/* ===================================================== ======================================= */
/* Table: "class "*/
/* ===================================================== ======================================= */
Create Table "class "(
"Classid" number (2) not null,
"Classname" varchar2 (24 ),
Constraint pk_class primary key ("classid ")
)
/
/* ===================================================== ======================================= */
/* Table: "student "*/
/* ===================================================== ======================================= */
Create Table "student "(
"Studentid" number (10) Not null,
"Studentname" varchar2 (4 ),
"Classid" number (2 ),
Constraint pk_student primary key ("studentid ")
)
/
Alter table "student"
Add constraint fk_student_reference_class foreign key ("classid ")
References "class" ("classid ")
/
2. Create a PDM, select database ---> reverse engineer database, and select using script files.
3. See the PDM generated automatically by the script as follows:
4. Export the database creation script after the model is generated
The imported model is used to modify and export the database creation script. the operation method is as follows:
1. Select database ---> Generate database. The following window is displayed:
Select the database user from none, select the table to be exported, and click OK. If the script cannot be properly generated and a model error is prompted, remove the check modle option in options, click OK to generate an SQL script,
Do not try to use the generated script because it may be a problem. Open the script with notepad or other tools and you will find that the "" number will be added to the s2ms name, use Ctrl + H to replace all values with null!