Tips on using power designer:
Must read: Concise description of Power Designer modeling capabilities (PowerDesigner 7.x Conceptual Data Model - Frequently Asked Questions). Although for a old version (7) still a valuable resource.It works with two distinct views:
- The conceptual data model (CDM): here you can define your entities and their relationships (one to many; one to one; etc) and the entities columns data types and atributes like mandatory etc.; One your model is done go to "Tools" -> "Generate Physical data model" to get to the next view;
- The Physical Data Model (PDM): here you can view the generated physical model created from the conceptual model. Once you are done you can generate the sql that will create the database by going to: "Database" -> "Generate Database...". Here you can select the database you want to generate the sql to (Oracle; Postgres; Mysql; etc);
Defining an auto_increment column
Defining an auto_increment columnControlling power designer foreign key generated names / customize fk names
For example if we add the following conceptual data model:By default power designer will generate the following foreign keys on the physical data model:
This naming convention is far from great because we will be confused on which id represents the sender and the receiver.
So we may which power designer to generate the following fk names instead:
To achieve this we changed the "FK column name template" option,
- from %.3:PARENT%_%COLUMN%
- to %REFR%_%COLUMN%
- Make sure you are on conceptual data model view otherwise you wont have access to this menus;
- Go to:
Other customization variables like the ones we used above (%REFR% and %COLUMN%) are available here under the "Foreign key name" header.
"Relationship Mapped to Overlapping Primary and Foreign Keys" aka "Dependent Relationship"
A Dependent Relationship from entity A to entity B defines A as partly or wholly identified by B's identifier. As an example, an order line might be identified by its order line number and the order number. This would be represented by a dependent relationship between the order line entity and the order entity.
This CDM will produce the following PDM:
Note that the Order primary key migrates to the Order Line table to become part of its primary key.
To draw this kind of relationship in Power Designer, just draw a normal relationship between the two entities and then double click it to edit its properties:
No comments:
Post a Comment