Powerdesigner's PDM (Physical Data Model) generates databases and reverse engineering (generate existing databases into PDM)

Source: Internet
Author: User
Tags dsn ibm db2 powerdesigner

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, go to the system DSN tag, click the Add button, select the database type DB2, and click Finish. It is displayed as follows: Enter datasource name "pdmtest" and 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 common server" that matches it ". Create method: Right-click workspace ----> New ------> physical data nodel in the left-side pane, select the data type you want from DBMS, and click OK, A new workspace is created.

2. Select reverse engineer database under the database menu. The database reverse engineering dialog box is displayed. Select using an ODBC data source and 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!

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/jiang_ideal/archive/2009/01/20/3838806.aspx

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.