How to generate database with PowerDesigner PDM and reverse generation of __ Database

Source: Internet
Author: User
Tags db2 dsn ibm db2 odbc powerdesigner

After PDM is done, the final goal is to convert it into a database entity. Here PDM presumably everybody knows is what file, right, English is PHYSIYC data model is also the physical datum models.
1. Confirm that the current PowerDesigner is set to the correct DBMS, that is, whether it is the type of database we want to build, and I am using sqlserver2000 here:
powerdesigner-> database-> Change the current DBMS, select your database type.

2. Configure PowerDesigner connection to the data source
Powerdesigner-> Database-> Configure Connection-> User DSN (or System DSN)-> Select, add your data source
3. Connection
powerdesigner-> database-> Connection-> set up the DSN confirmation you just established.
OK, after setting up the connection, we can generate the SQL statement for PDM.
4. Database generation
Powerdesigner-> database-> Build the database-> configured (by default), then choose OK.
Get the SQL script statement, we all know how to do it, put it in the SQL Query Analyzer to execute it.


PowerDesigner Reverse engineering to generate PDM from existing database

In the process of data modeling, we set up the conceptual data model, generate the physical data model by forward engineering, generate database script, and finally generate the relational database with the physical data model, and now turn the relational database to generate the physical data model by reverse engineering.
Advantages:

The model for using the database can be generated in the lost data model or the database model inconsistent with the existing database

Disadvantages:

In the restored model, there may not be any Chinese annotations, no foreign key correspondence (fields and index relationships are gone)

Premise:

1, confirm that the database to generate the model is up to date, and that you can use the

2, install PowerDesigner software

Specific steps to operate:

First, establish an ODBC data source

1, open the system ODBC data source, location Control Panel--management tools-Data Source (ODBC)

2, select the System DSN, click on the Add button, will pop up the following interface, select the database match with the driver

3, click Finish, pop-up data source name (custom), and select the database you want to connect, as shown in the following figure

4, after the selection is determined, the data source is established successfully, you can double-click the data source name for the connection test, as shown in the following figure

5, this data source is established, of course, these can also not be built here, in the PowerDesigner can also be established, to establish methods for

Select Database->configure connections, go to the System DSN tab, click the Add button, select the database type DB2, click Finish. The display is as follows: Enter DataSource Name "Pdmtest", enter servername "Database", Configuration complete. As shown below:

Second, reverse generation in PowerDesigner

1, open the PowerDesigner tool, create a PDM file, and select the matching database type "IBM DB2 UDB 8.x Common Server". The creation method is: Right click on the left panel of the workspace---->new------>physical Data Nodel, in the DBMS select the type of data you want to choose, click OK, then set up a new work space.

2, select Reverse Engineer Database under the Database menu, pop-up Database Reverse Engineering dialog box, choose Using an ODBC data source "S2ms", As shown in the following illustration:


3, click OK, show all the tables, views, users in this database (this select the user of this database). When selected, convert to PDM. Pictured below


4, select OK, click OK, then generate the model.


Iii. using script to generate the model

If you don't just have a database that you're making, you've got a script to build the library, so you're rich. Because of the model generated by the. SQL script, there is no disadvantage of using database generation, as follows:

Ii. generating PDM by reverse engineering of SQL script

1, database SQL script file Crebas.sql. Below is the script instance:
/*==============================================================*/
/* Database Name:physicaldatamodel_1 * *
/* DBMS name:oracle Version 9i * *
/* Created on:2003-07-13 10:49:08 * *
/*==============================================================*/
/*==============================================================*/
/* Table: "Class" * *
/*==============================================================*/
CREATE TABLE "Class" (
' ClassID ' number (2) is not NULL,
"ClassName" VARCHAR2 (24),
Constraint Pk_class primary KEY ("ClassID")
)
/
/*==============================================================*/
/* Table: "Student" * *
/*==============================================================*/
CREATE TABLE "Student" (
' StudentID ' number is 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, or create a PDM, select database--->reverse Engineer database, select using files.


3, see the automatically generated by the script related PDM is as follows:

Iv. to export the database build script after generating the model

Model, of course, is used to modify and export the library script, the following methods of operation

1, select database--->generate database pops up the following window

Select the database user in none of the users, optionally the table to be exported, and then click OK, and if the script hint model error is not generated correctly, remove the check modle option in the options in the diagram above, click OK, and generate the SQL script.

The generated script is not in a hurry to use, because there may be a problem, with Notepad or other tools to open the script, you will find in the name of the s2ms will be added "", with Ctrl+h, replace All "empty", it is done

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.