Powerdesigner tutorial-Conceptual Data Model

Source: Internet
Author: User
Tags powerdesigner
1. Conceptual Data Model Overview

The conceptual data model is also called the information model. It is based on the entity-relationship (E-R) theory and expands this theory. It models information from the user's point of view and is mainly used for Conceptual Design of databases.

Generally, people first abstract the real world into a conceptual world, and then convert the conceptual world into a machine world. In other words, objective objects in the real world are first abstracted as entities and relationship. They do not depend on a specific computer system or a DBMS system, this model is what we call CDM, and then converts CDM to the data model supported by a DBMS on the computer. This model is the physical data model, that is, PDM.

CDM is a set of strictly defined model elements that accurately describe the system'sStatic, dynamic, and integrity constraints, IncludingData structure, data operations, and integrity constraintsThree parts.
1) Data structures are expressed as entities and attributes;
2) The data operation table is the insert, delete, modify, query, and other operations of records in the entity;
3) integrity constraints are expressed as integrity constraints of data (such as data types, checks, rules, etc.) and integrity constraints of reference between data (such as links and inheritance links );

Ii. Definitions of entities, attributes, and identifiers

Entity, also known as an instance, corresponds to "events" or "things" that can be different from other objects in the real world ". For example, each student in the school and each operation in the hospital. Each entity can be used to describe a set of properties of entity features, which are called attributes. An entity is described by several attributes. For example, a student entity may consist of attributes such as student ID, name, gender, date of birth, department, and year of admission.

An entity set is a set of entities of the same type and nature. For example, a set of all students in a school can be defined as a "student" entity set, each entity in the "student" entity is subject to a student ID, name, gender, date of birth, department, and year of admission.

Entity type is a set of common properties of each entity in an entity set. For example, the entity type of "patient" is: Patient {outpatient number, name, gender, age, ID card No .............}. An object is an instance of the object type. When the meaning is clear, the object and object types are usually used interchangeably. Each entity in an object type contains one or more attributes that uniquely identify it. These attributes are called identifiers of an object type. For example, a student ID is an identifier of a student entity type, "name", "Date of Birth", and "email address" form the "Citizen" entity type identifier. Some object types can have several groups of attributes that act as identifiers. select one of these attributes as the primary identifier of the object type, and others as the secondary identifier.

3. entity, attribute, and identifier expression

4. Create a conceptual data model

1) Select File --> new. In the displayed dialog box, select CDM model (Conceptual Data Model) to create a model.

2) create a conceptual data model. To give a brief introduction to the current workspace. (More details later)

3) Select the newly added CDM model, right-click the model, and select the "properties" attribute in the pop-up menu. the pop-up dialog box is displayed. In the "General" label, you can enter the name of the created model,Code, Description, creator, version, and default chart. Enter the description and description in the "Notes" tab. For more tags, click "More>.

5. Define entities

1. Create an object
1) in the CDM graphic window, click entity tool on the tool option edition, and then click a blank area in the graphic window. An entity symbol is displayed at the clicked position. Click the pointer tool or right-click to release the entitiy tool.

2) double-click the newly created object symbol to open the following icon window. In the "General" tab of the window, you can enter the object name, code, description, and other information.

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: It is generally used as the physical name of an object during model conversion. For example, if you convert the code of an object attribute to a column name in a database, you do not have to worry about what the object will be called in the future, generally, use the same name.

Generate: the default state is selected. If the State is canceled, this entity is ignored when it is converted to another model.

2. Add Object Attributes
1) You can add attributes to the "attribute" option tag in the preceding window, as shown in.

Note:
The "add attribute" and "reuse existing data items" functions in the data item are related to the unique code of the data item in the model and the allow reuse option.
The P column indicates whether the property is the primary identifier; the D column indicates whether the property is displayed in the graphic window; The m column indicates whether the property is mandatory, that is, whether the column is null.

If an object property is mandatory, it must be assigned a value in each record and cannot be blank.

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.

2) In the displayed window, click the insert attribute button to bring up the attribute dialog box, as shown in.

3. Define attribute check Constraints

1) Standard inspection of defining attributes
Standard Check ConstraintsIs a set of expressions that ensure the attribute is valid. In the Properties window of object properties, open the check tab.

On this tab, you can define the standard check constraints for attributes. The meanings of parameters in the window are as follows:

Parameters Description
Minimum Acceptable minimum number of attributes
Maximum Maximum number of acceptable attributes
Default Default value provided by the system when the attribute is not assigned a value
Unit Units, such as kilometers, tons, and Yuan
Format Attribute data display format
Lowercase All attribute values are lowercase letters.
Uppercase All values assigned to an attribute are uppercase letters.
Cannot modify This attribute cannot be modified once it is assigned a value.
List of Values Attribute Value assignment list. No value exists except the value in the list.
Label Label of attribute List Value

2) additional checks for defining Properties
When standard checks or rules cannot meet the requirements of the check, you can go to the server subpage on the additional checks tab, use the variables % MINMAX %, % listval %, % rules %, % upper %, and % lower % in SQL statements to define standard and rule,

% MINMAX %, % listval %, % upper %, % lower %
Minimum and maximum, list values, uppervalues, and lowervalues defined in standard check

% Rules %
Validity rule expression defined on the Expression tab of the Rules Properties window

Vi. identifier

An identifier is a set of one or more attributes of an object. It uniquely identifies an instance in an object. It should be emphasized that the identifiers in CDM are equivalent to primary keys or candidate keys in PDM. Each entity must have at least one identifier. If an object has only one identifier, it is the primary identifier of the object. If an object has multiple identifiers, one of them is specified as the primary identifier, and the other identifiers are secondary identifiers.

1. Define the Primary and Secondary identifiers
1) double-click an object to display the object Properties dialog box. You can define object identifiers on the identifiers tab. As shown in

2) Select "primary identifier" in the first line, click the attribute button, or double-click "primary identifier" in the first line. The Properties dialog box is displayed,

3) Select the "attributes" tab and click "add attributes". In the displayed window, select an attribute as the identifier.

VII. Data items

A data item is the smallest unit of information storage. It can be attached to an object as an attribute of an object.
Note: Data items that are not attached to any entity are allowed in the model.

1. Create a data item
1) use the "model" ---> data items menu to display the list of existing data items in the window that appears. Click "add a row" to create a new data item,

2) Of course, you can continue to set the code, ype, length, and other information for specific data items. This is not detailed here.

2. unique code options and reuse options for data items
Use tools ---> model options-> model settings. In the data item group box, define the unique code option (unique code) and reuse option (allow reuse) of the data item ).
Note:
If the unique code check box is selected, each data item has a unique code in the same namespace, and allow reuse is selected, a data item can act as the attribute of multiple entities.

3. Add data items to an object
1) double-click an object symbol to open the object attribute window.
2) Click the attributes tab to open the window as shown in

Note:
The difference between Add a dataitem and reuse a dataitem is that
When you add a dataitem, select an existing data item. The system automatically copies the selected data item. If the uniquecode option is set, the system automatically generates a unique number for the code of the new data item during the replication process. Otherwise, the code is exactly the same as the selected data item.

In the case of reuse a dataitem, only references do not add, that is, references existing data items as new object data items.

8. Contact

Relationship refers to the connection between the entity set and the instances in the entity set.

Entities can be associated by association. It corresponds to an object and an object set. A link can also be divided into a link and a contact set. A contact set is a link between an object set, and a link is a link between entities, which is oriented. A contact and a contact set can be referred to as a contact if the meaning is clear.

There are four types of links according to the number of instances in the entity type, that is, one-to-one (one-to-one) and one-to-many (one-to-many) contact, multi-to-one contact, and multi-to-one contact ).

1. Establish contact
In addition to public tools, the CDM tool option Board also includes other object generation tools as shown in.

After creating two entities in the graphic window, click the "Create contact between entities" tool, click an entity, drag the cursor to another entity while pressing the left mouse button, and release the left mouse button, in this way, the contact is created between the two entities, right-click the graph window, and release the relationship tool. As shown in

<! -- [If! VML] --> <! -- [Endif] -->

After establishing a contact between the two entities, double-click the contact line to open the contact feature window ,.

2. four basic connections
That is, one-to-one connections, one-to-many connections, one-to-one connections, and many-to-many connections ).

3. Other Special contacts

In addition to four basic connections, there are also identify relationship, non-standard relationship, and recursive relationship between the entity set and the entity set ).

Calibration contact:
Each object type has its own identifier. If there is a link between two entity sets, when one entity type identifier enters another entity type and forms its identifier together with the entity type identifier, this kind of contact is called a calibration contact or a dependency contact. The opposite is called non-standard or non-dependent contact.
Note:
In a non-standard relational system, some instances in an entity set depend on instances in another instance set. In this dependency relationship, each entity must have at least one identifier. In the calibration contact, the full instance of an entity set is completely dependent on the instance of another entity set. In this dependency relationship, an entity must have at least one identifier, another entity does not have its own identifier. An entity without an identifier uses its dependent entity identifier as its own identifier.

In other words, in the calibration contact, an entity (Course Selection) depends on one entity (student), then the entity (student) must have at least one identifier, and (Course Selection) an entity may not have its own identifier. An entity without a logo identifier can use the entity (student) identifier as its own identifier.

Recursive contact:
Recursive link is a link between instances in the entity set. It is usually called an anti-link. The link between different entity sets in the same object type is also called recursive link.

For example, if there are many employees in the "employees" entity, there must be a relationship between leaders and leaders. Another example is that the entity in the "student" entity contains the "class monitor" and "normal student" sub-entity sets. The link between these two sets is a recursive link. When creating a recursive link, you only need to click the "Create link between objects" tool to drag a part of the object to another part of the object.

3,Define contact features

Double-click the relationship symbol to go to the link property page. In the detail project, we can define the relationship between two entities in detail, for example:

    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 relationship between the Department and the employee is as follows:

  • 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 "" from the drop-down list, for example:

The last defined relationship is shown in the concept diagram as follows:

Note: In Power Designer, 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, which will be discussed later.

Dependency)

In the preceding example, we assume that an employee has a vacation, and each time an employee takes a vacation, the start and end days of the employee's vacation must be recorded. The leave is in the unit of days, one employee and one start day determine a vacation. According to this business description, we know that for a vacation, it must depend on the entity "employee", that is, a vacation, there must be a subject employee. On the basis of the previous model, we add an entity named "holiday", which defines the start day and end day of the holiday. Here we do not need to define a duplicate employee number, instead, dependency is used to indicate that the object "holiday" depends on the object "employee". The relationship definition is as follows:

In the "holiday" object, we need to set the start date as the primary key identifier. The start date is used together with the employee number in the dependent entity as the identifier of the entity "holiday" to uniquely identify a holiday. This dependency is shown in the concept diagram as follows:

On the way, we can see that there is an extra triangle ▲ arrow at the end of the "holiday" object, which means that the entity "depends on another entity referred to by the arrow, in the transformed physical model, the empno of the object "employee" will not only serve as a foreign key, it also appears as the primary key (composite primary key together with startdata ).
Use dominant role

When the relationship between two entities is 1 .. 1 hour (although this relationship is rare, it is common in object-oriented design methods and the primary keys in dependent entities usually overlap with external keys). You need to specify these two entities explicitly, which is a parent object and which is a dependent object. Otherwise, when the system converts a conceptual model to a physical model, it cannot determine which end of the system needs to generate a foreign key, in this case, the "dominant role" option is used. This option is only available in 1 .. 1. Assume that some employees in an enterprise have a system account and a unique account. These employees need to save additional information, such as the account name and password. We added a new entity "user", which is 1 .. 1. Because a user account must belong to one employee, and an employee may not have a user account, we define the entity "employee" to govern the entity "user ". At the same time, because "user" depends on "employee", a dependency from the former to the latter is defined, such:

In the dominant role option, the arrow refers to the entity that is governed, that is, the dependent entity. In the model diagram, a capital letter "D" enclosed in parentheses appears on the side of the dominant object ".

In the transformed physical model, in the table user, empno is used as a separate primary key and is also a foreign key that references the employee table.

Process the relationship between many-to-many (N. N)

In the conceptual model, we rarely see the direct n between two entities .. n relationship. In this case, we usually add an intermediate entity. In Power Designer, we provide a special symbol for it, called "association ". Consider the following situations:

Employees with accounts in an enterprise have different operation permissions in the system, which are managed by user roles. permissions have been assigned to multiple roles, A user account must belong to at least one role and may belong to multiple roles at the same time. A role can contain 0 or more user accounts. According to the above description, we add an object "role", which is n between it and the object "user .. to express this relationship, we add an association and use the association link to establish a relationship with the other two entities, as shown below:

Using a common entity, reasonably defining the relationship, and selecting the "dependent" option can replace "association", but using "association" is more convenient and intuitive, make the model easier to understand and reduce errors that may be caused by carelessness.

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.