I. Define entities
Double-click the object symbol to go to the object attribute page.
1. General Project
Name: identifies an object in the model and is generally used for displaying the model on the interface (this can be changed by changing the option settings ). In a model, Entity names cannot be repeated.
Code: the physical name of an object during model conversion. Name can be queried in Chinese and English. Code is the final Table Name generated when writing a program.
Generate: the default state is selected. If the State is canceled, this entity is ignored when it is converted to another model.
2. Attributes Project
The items in the table below in the window are very similar to the definition of a table structure, but the data type is abstracted and uses an independent representation method, which is not related to any specific database system.
Add attributes for the current object in this project.
The following three columns of CheckBox represent:
- M: This attribute cannot be null.
- P: This attribute is the primary key identifier.
- D: Display Property
Click "Crtl + U" to call out the "Custom column filter" window. You can select the ones listed in the window and hidden ones based on your preferences and actual needs. Use the shortcut key "Crtl + E" to allow or disable the current filter.
Ii. Define relationships
Double-click the Relationship symbol to go to the link property page,
1. General Project
In this example, the business relationship is described as follows: a department Has multiple employees, and we use "Has" as the name of the relationship.
We can also describe that multiple employees Belong to one department. Can we use "Belong to" as the relationship name? It is generally not recommended to do this. In the concept diagram, there is an agreement that the name of the link is from "1, meaning of reading from "1" to "n. In this example, "1" is on the department side and reads the semantics from the Department one to the employee side, that is, the Department Has multiple employees (Has.
2. Detail Project
Assume that the Department and Employee have the following relationships:
- A department may have multiple employees, and a new Department may not have any employees;
- An employee must belong to only one department at the same time;
Based on the above relationship, we modify the property page. The default direction of department-employee is 0, n, and the direction of employee-department is changed to Mandatory ), or select "1, 1" from the drop-down list ".
Note: In PowerDesigner, a "horizontal line" near the object represents a mandatory constraint, and "hollow circle" represents no mandatory constraint, that is, this party can have no object Association; the "non-branch" line represents the relationship of "1", and the "branch" line represents the relationship of "many. The above four symbols can combine 16 types of relationships (including reverse ). The relationship of "many-to-many" is generally decomposed by providing an intermediate entity. Therefore, in many conceptual charts, the actual "many-to-many" relationship does not exist.
In addition, there are two items in the Link Attributes: Dominant role and Dependent, which can represent more complex relationships.
Remember: In the concept diagram, foreign keys are automatically created by relational Relationship, and do not need to be manually created. Otherwise, redundant keys will be generated. Therefore, when designing, pay attention to the fields of the object and the relationship between objects, especially the many-to-many and dependency relationships.
Note the following before converting CDM to PDM:
The digoal name cannot be changed. In the tree chart, if you select the red Symbol to overwrite the modification, if you do not select the Symbol to protect the modification.
Integrity constraints are applicable to the link:
Restriction: modification or deletion is not allowed. If the primary key of the primary table is modified or deleted, if the Sub-table contains a sub-record, an error message is displayed. This is a lack of integrity settings.
Set Null: if the foreign key table can be empty, if you modify or delete the primary key of the primary table, Set the foreign key column referenced in the child table to Null ).
Set Default: if the Default value is specified, When you modify or delete the primary key of the primary table, Set the foreign key referenced in the subtable to the Default value ).
Cascade: when the primary key of the master table is changed to a new value, the foreign key value of the sub-table is modified accordingly. Or when the primary key record of the master table is deleted, delete the records of Foreign keys in the sub-table.
Note that when you understand the preceding constraints, the master table is used to capture the operation, and the sub-Table operations are relative to the master table. The operation methods are Update and Delete.
Iii. Internal Mechanism
1. When copying a column in PowerDesigner, there is actually a link. Changes to the source column are also reflected in the copy column;
2. General steps for Database Design: CDM determines the main structure -- & gt; generates PDM -- & gt; modifies the PDM and generates CDM if necessary;
3. for Oracle, table setting options (such as tablespace GPSSYSTEM) can be used to create the correct tablespace, and using index tablespace GPSINDEX) create an index in the correct tablespace;
Domain: in short, it is a user-defined type, but the Domain can also define its value range or default value. Using a Domain reduces the workload of maintaining the field type, it also reduces data inconsistency.
Reference: In PowerDesigner, you can set the integrity of the Reference. The base number of the Reference ranges from 0 to n, you can Set the modification and deletion constraints to None, Restrict, Cascade, Set Null, and Set Default. Because insert is included in the update operation, there is no separate insert constraint.
Different settings of constraints have different effects. For example, modify the settings (delete the same settings ):
None: the parent table is modified, and the child table is not affected.
Restrict: Modify the parent table. If the corresponding records of the child table exist, an error occurs.
Cascade: Modify the parent table. If the child table exists, modify the table accordingly.
Set Null: Modify the parent table. If the child table exists, it is Set to Null.
Set Default: Modify the parent table. If the child table exists, Set the Default value accordingly.
Storage: different databases have different concepts. sybase is called a Device and SQL Server is called a File or File group ), oracle is called a table space ).