PowerDesigner reverse engineering generates PDM models and databases

Source: Internet
Author: User

Original http://www.cnblogs.com/springside4/archive/2012/04/16/2481149.html

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. System database designers hope to seamlessly integrate database design and relational database generation. How to ensure two-way synchronization between physical data models and their corresponding data libraries becomes a key aspect of data modeling.

As a powerful Case tool, Powerdesigner provides us with convenient reverse engineering features. You can add the structure information of all popular backend databases (including Sybase, DB2, and Oracle) to the physical data model and conceptual data model of PowerDesigner through reverse engineering, including tables, indexes, triggers, and views.

This document describes only the reverse engineering of PDM (physical data model.

Reverse Engineering in PDM refers to the process of generating PDM from the user database of the existing DBMS or the SQL script of the existing database. There are two types of reverse engineering objects: 1) connecting to the database through the ODBC data source 2) existing database SQL scripts.

The system environment in this example is as follows:

1. The database has been created, and the access user and password settings are complete. The database is Oracle9i.

2. the ODBC data source has been created by oracle's Net Configuration Assistant. The local network Naming Service "Database" is used ".

3. SQL script example crebas. SQL.

4. Powerdesigner9.5 has been installed successfully.

1. Use the data source to connect to the database and reverse engineer to generate PDM

1. Configure user database connection Parameters

Select Database-> configure connections to go to the system dsn tag,

Click Add, select Oracle as the database type, and click Finish. Enter DataSource Name "PDMTest" and ServerName "Database". The configuration is complete.

Click "Test Connect" and enter ServerName "Database", user name and password. If the connection is successful, the following information is displayed:

Choose Database? Connect, select the odbc data source, and enter ServerName "Database", user name, and password. If no prompt is displayed, the connection is successful. At the same time, you can use the Database? View the Connection Information.

2. Set reverse engineering options to generate pdm

Create a PDM file and select the matched Database Type "oracle9i ".

Select Database? Reverse Engineer Database. The Database Reverse Engineering dialog box is displayed. Select Using an ODBC data source and select ODBC data source "PDMTest"

Click OK to display all tables, views, and users in the database. Select as needed and convert to pdm.

3. View data

For the generated PDM, right-click a table graphical symbol and select View Data to access the Data in the table.

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 and select Database? Reverse Engineer Database, select Using script files.

3. See the PDM generated automatically by the script as follows:

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.

 

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. System database designers hope to seamlessly integrate database design and relational database generation. How to ensure two-way synchronization between physical data models and their corresponding data libraries becomes a key aspect of data modeling.

As a powerful Case tool, Powerdesigner provides us with convenient reverse engineering features. You can add the structure information of all popular backend databases (including Sybase, DB2, and Oracle) to the physical data model and conceptual data model of PowerDesigner through reverse engineering, including tables, indexes, triggers, and views.

This document describes only the reverse engineering of PDM (physical data model.

Reverse Engineering in PDM refers to the process of generating PDM from the user database of the existing DBMS or the SQL script of the existing database. There are two types of reverse engineering objects: 1) connecting to the database through the ODBC data source 2) existing database SQL scripts.

The system environment in this example is as follows:

1. The database has been created, and the access user and password settings are complete. The database is Oracle9i.

2. the ODBC data source has been created by oracle's Net Configuration Assistant. The local network Naming Service "Database" is used ".

3. SQL script example crebas. SQL.

4. Powerdesigner9.5 has been installed successfully.

1. Use the data source to connect to the database and reverse engineer to generate PDM

1. Configure user database connection Parameters

Select Database-> configure connections to go to the system dsn tag,

Click Add, select Oracle as the database type, and click Finish. Enter DataSource Name "PDMTest" and ServerName "Database". The configuration is complete.

Click "Test Connect" and enter ServerName "Database", user name and password. If the connection is successful, the following information is displayed:

Choose Database? Connect, select the odbc data source, and enter ServerName "Database", user name, and password. If no prompt is displayed, the connection is successful. At the same time, you can use the Database? View the Connection Information.

2. Set reverse engineering options to generate pdm

Create a PDM file and select the matched Database Type "oracle9i ".

Select Database? Reverse Engineer Database. The Database Reverse Engineering dialog box is displayed. Select Using an ODBC data source and select ODBC data source "PDMTest"

Click OK to display all tables, views, and users in the database. Select as needed and convert to pdm.

3. View data

For the generated PDM, right-click a table graphical symbol and select View Data to access the Data in the table.

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 and select Database? Reverse Engineer Database, select Using script files.

3. See the PDM generated automatically by the script as follows:

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.