Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw ER Diagram with powerdesigner

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use powerdesigner to draw ER map", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use powerdesigner to draw ER map" bar!

Powerdesigner draws ER diagram

ER diagram is CDM diagram-Conceptual Data Modal

CDM can be converted into PDM, OOM, LDM, etc. Please check for details

In general, CDM diagrams are created during the outline design phase, and PDM diagrams are generated based on CDM diagrams.

I. Overview of Conceptual data Model

Data model is the abstraction of data features in the real world. The data model should meet three requirements:

1) be able to simulate the real world realistically

2) easy to understand

3) easy to be realized by computer

Conceptual data model, also known as information model, is based on the theory of entity-relation (Entity-RelationShip), which is extended. It models the information from the user's point of view and is mainly used in the conceptual design of the database.

Usually people first abstract the real world into a conceptual world, and then turn the conceptual world into a machine world. In other words, it abstracts the objective objects in the real world into Entity and Relationship, which does not depend on the specific computer system or some DBMS system. This model is what we call CDM; and then converts the CDM into the data model supported by a certain DBMS on the computer. This model is the physical data model, namely PDM.

CDM is a set of strictly defined model elements, which accurately describe the static characteristics, dynamic characteristics and integrity constraints of the system, including data structure, data operation and integrity constraints.

1) data structures are expressed as entities and attributes

2) data operations are expressed as insert, delete, modify, query and other operations of records in the entity.

3) Integrity constraints are expressed as self-integrity constraints of data (such as data types, checks, rules, etc.) and referential integrity constraints (such as associations, inheritance relationships, etc.) between data; II. Definition of entities, attributes and identifiers

Entities (Entity), also known as instances, correspond to "events" or "things" that can be distinguished from other objects in the real world. For example, every student in the school, every operation in the hospital.

Each entity has a set of properties used to describe the characteristics of the entity, called attributes, and an entity is described by several attributes. For example, the student entity can be composed of student number, name, gender, date of birth, department, year of enrollment and so on.

An entity set (Entity Set) is a collection of entities of the same type and properties. For example, the collection of all students in a school can be defined as a "student" entity set, and each entity in the "student" entity set has the nature of student number, name, gender, date of birth, department, year of enrollment and so on.

The entity type (Entity Type) is a collection of common properties of each entity in the entity set, for example, the "patient" entity type is: patient {outpatient number, name, gender, age, ID number.}. An entity is an instance of an entity type, and entities and entity types are usually used interchangeably when the meaning is clear.

Each entity in an entity type contains one or a set of attributes that uniquely identify it. These attributes are called identifiers of the entity type (Identifier). For example, "student number" is the identifier of the student entity type, and "name", "date of birth", and "letter address" together constitute the identifier of the "citizen" entity type.

Some entity types can have several sets of attributes as identifiers, one of which is selected as the primary identifier of the entity type and the other as the secondary identifier.

III. Expression of entities, attributes and identifiers

This paper introduces the PowerDesigner conceptual data model and the creation of entities and attributes.

I. New Conceptual data Model

1) Select File-- > New, pop up the dialog box shown in the figure, and select CDM model (that is, conceptual data model) to build the model.

2) complete the creation of the conceptual data model. The following illustration provides a brief introduction to the current workspace. (more details later)

3) Select the new CDM model, right-click, select the "Properties" property item in the pop-up menu, and pop up the dialog box shown in the figure. You can enter the name, code, description, creator, version, default diagram and other information of the model in the "General" tab. You can enter relevant description and description information in the "Notes" tag. Of course, if there are more tags, you can click the "More > >" button, which will not be explained in detail here.

Create a new entity

1) in the graphics window of CDM, click the Entity tool on the tools options, and then click in the space of the graphics window, and an entity symbol appears where you click. Click the Pointer tool or right-click to release the Entitiy tool. As shown in the figure

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

Third, add entity attributes

1) you can add attributes to the "Attribute" option tab of the above window, as shown in the following figure.

Note:

The "add attributes" and "reuse existing data items" functions in data items are related to the Unique code and Allow reuse options of Data Item in the model.

The P column indicates whether the attribute is the primary identifier; the D column indicates whether the attribute is displayed in the graphics window; and the M column indicates whether the attribute is mandatory, that is, whether the column is null.

If an entity attribute is mandatory, the attribute must be assigned in each record and cannot be empty. 2) in the window shown above, click the insert Properties button and pop up the Properties dialog box, as shown in the following figure.

Note: the concept of domain is involved here, that is, a standard data structure that can be applied to the properties of data items or entities.

Standard check constraints that define attributes

A standard check constraint is a set of expressions that ensure that an attribute is valid. In the properties window of the entity properties, open the check tab shown in the figure.

On this tab, you can define standard check constraints for attributes, and the meaning of the parameters for each item in the window is as follows

Parameter description the minimum acceptable number of Minimum attributes the maximum acceptable number of Maximum attributes when the Default attribute is not assigned, the default value Unit units provided by the system, such as kilometer, ton, meta format attribute data display format Lowercase attribute assignment all become lowercase letter Uppercase attribute assignment all become uppercase letter Cannot modify once assigned, the List Of Values attribute assignment list can no longer be modified, except for the values in the list Cannot have other values Label attribute list values label

Second, additional checks for defining attributes

When Standard checks or Rules does not meet the inspection requirements, you can define Standard and Rule by using the variables% MINMAX%,% LISTVAL%,% RULES%,% UPPER%,% LOWER% in the SQL statement on the Server sub-page of the Additional Checks tab, as shown in the figure.

MINMAX%, LISTVAL%, UPPER%, LOWER%

Minimum and Maximum, List values, uppervalues, lowervalues defined in Standard Check

% RULES%

Validity rule expressions defined in the Expression tab of the Rules properties window

I. Identifier

An identifier is a collection of one or more attributes in an entity that can be used to uniquely identify an instance of an entity. It is important to emphasize that identifiers in CDM are equivalent to primary keys or candidate keys in PDM.

Each entity must have at least one identifier. If an entity has only one identifier, it is the primary identifier of the entity. If the entity has multiple identifiers, one of them is designated as the primary identifier and the rest is the secondary identifier.

Second, if primary and secondary identifiers are defined

1) Select an entity and double-click the properties dialog box for the pop-up entity. Entity identifiers can be defined on the Identifiers tab. As shown in the following figure

2) Select the first line "Primary Identifier", click the Properties button or double-click the first line "Primary Identifier", and pop up the Properties dialog box, as shown in the figure.

3) Select the "Attributes" tab, then click the "Add Attributes" tool, pop up the window shown in the figure, and select an attribute as the identifier.

I. data items

A data item (Data Item) is the smallest unit of information storage, which can be attached to an entity as an attribute of the entity.

Note: data items that are not attached to any entity are allowed in the model.

II. Create new data items

1) use the "Model"-- > Data Items menu to display a list of existing data items in the open window. Click the "Add a Row" button to create a new data item, as shown in the figure.

2) of course, you can continue to set Code, DataType, Length, and so on for specific data items. I will not elaborate on it here.

Unique code options and reuse options for data items

Use Tools--- > Model Options- > Model Settings. Define unique code options (Unique Code) and reuse options (Allow Reuse) for data items in the Data Item group box.

Note:

If you select the Unique Code check box, each data item has a unique code in the same namespace, while selecting Allow reuse, a data item can act as an attribute of multiple entities.

Add data items to the entity

1) double-click an entity symbol to open the properties window for that entity.

2) Click the Attributes tab and open the window shown below

Note:

The difference between Add a DataItem and Reuse a DataItem is that

In the case of Add a DataItem, select an existing data item, and the system will automatically copy the selected data item. If you set the UniqueCode option, the Code of the new data item will automatically generate a unique number during the replication process, otherwise it will be exactly the same as the selected data item. In the case of Reuse a DataItem, only references are not added, that is, data items that already exist are referenced as data items of the new entity.

I. contact

Relationship refers to the connection between the entity set or the instances within the entity set.

Entities can be related to each other through contact. Corresponding to the entity and the entity set, the relation can also be divided into the connection and the contact set. The connection set is the relationship between the entity sets, the connection is the relationship between the entities, and the connection is directional. Both the contact and the contact set can be called connections when the meaning is clear.

According to the quantitative correspondence between instances in entity types, connections can usually be divided into four categories, namely one-to-one (ONE TO ONE) connections, one-to-many (ONE TO MANY) connections, many-to-one (MANY TO ONE) connections and many-to-many connections (MANY TO MANY). Second, establish contact

In addition to the common tools, other object generation tools shown in the following illustration are included in the CDM tool palette.

After creating two entities in the graphics window, click the "make a connection between entities" tool, click an entity, press the left mouse button while dragging the cursor over another entity and release the left mouse button, thus creating a connection between the two entities, right-click the graphics window, and release the Relationship tool. As shown in the following figure

Three and four basic connections

That is, one-to-one (ONE TO ONE) contact, one-to-many (ONE TO MANY) contact, many-to-one (MANY TO ONE) contact and many-to-many connection (MANY TO MANY). As shown in the figure

IV. Other types of special connections

In addition to the four basic relationships, there are calibration connections (Identify Relationship), uncalibrated relationships (Non-Identify RelationShip) and recursive relationships (Recursive Relationship) between entity sets and entity sets.

Calibration contact:

Each entity type has its own identifier. If a relationship occurs between two entity sets, and the identifier of one entity type enters the other entity type and forms its identifier with the identifiers in that entity type, this connection is called a calibration connection, also known as a dependency connection. On the contrary, it is called uncalibrated relation, also called independent relation.

Note:

In uncalibrated relationships, some instances in one entity set depend on instances in another instance set, in which each entity must have at least one identifier. In the calibration connection, all the instances in one entity set are completely dependent on the instances in the other entity set, in which one entity must have at least one identifier, while the other entity can not have its own identifier. An entity without an identifier uses the identifier of the entity it depends on as its own identifier.

In other words, in a calibration connection, an entity (elective course) depends on an entity (student), then (student) entity must have at least one identifier, and (elective) entity may not have its own identifier. entities without identifiers can use the identifier of the entity (student) as their own identifier.

Recursive contact:

A recursive relation is a relationship between instances within an entity set, which is usually vividly called a reflexive relation. Relationships between different sets of entities in the same entity type are also called recursive relationships.

For example, there are a lot of workers in the "employee" entity, and there must be a relationship between the leader and the leader. For example, the entity in the "student" entity letter contains the "monitor" sub-entity set and the "ordinary student" sub-entity set, and the relationship between these two sub-entity sets is a recursive relation. To create a recursive relationship, simply click the create relationships between entities tool to drag from one part of the entity to another part of the entity. As shown in the picture

Fifth, define the characteristics of the connection

After the contact is established between the two entities, double-click the contact line to open the contact properties window, as shown in the figure.

6. Define the role name of the contact

There is a grouping box in each of the two directions of the connection, in which the parameters only work in this direction. Role Name is the role name, which describes the role of the connection in that direction, usually using a verb or verb group table.

For example, you should fill in "own" in the "Student to course" group box, and "belong to" in the "To students" group box. Here is just an example, some words may not be reasonable.

VII. Defining the compulsion of a link

Mandatory table contact in this direction of the mandatory relationship. Select this check box to create a vertical line on the contact line. Not selecting this check box means that the contact is optional in this direction, creating a small circle on the contact line.

VIII. The cardinal number of relevant links

The connection is directional and has a cardinality in each direction.

Give an example

The relationship between the two entities of "department" and "student" is one-to-many, in other words, the connection between "student" and "department" is many-to-one. Moreover, a student must belong to one department, and can only belong to one department, not zero departments, so the cardinality from the "student" entity to the "department" entity is "1 minute 1". Considering from the other direction of the connection, a department can have multiple students or no students, that is, zero students, so the cardinality of the connection in this direction is "0pr n", as shown in the figure.

CDM is the first model that most developers create when using PD, and it is also the highest-level abstraction of the entire database design. CDM is based on the traditional theory of ER graph model. There are three main elements in ER graph: entity, attribute and relation. The entity type corresponds to the Entity in CDM, and the attribute corresponds to the Attribute of each Entity in CDM, which is basically one-to-one in concept. But in the connection, CDM has a relatively large expansion, in addition to retaining the original RelationShip concept of the ER diagram, but also added two kinds of Association,Inheritance entity relations, let's take a look at the usage of these relationships and the difference between them respectively (the red toolbar button in the following figure is used to add these relationships to the entity).

In addition, before introducing all these elements in CDM, the author first gives a very simple CDM diagram, which is a model of the school scene we are most familiar with. All the concepts mentioned below are reflected in the diagram, which you can compare when you look at the following:

one。 RelationShip (contact)

First give the definition of connection in the PD manual: "A relationship is a link between entities. For example, in a CDM that manages human resources, the relationship Member links the entities Employee and Team, because employees can be members of teams. This relationship expresses that each employee works in a team and that each team has employees." It can be seen that perhaps the concept of connection is really too simple, so it is not so easy to express, so the PD document also uses an example to illustrate what kind of situation we think there is a connection between the two entities.

When we talk about the relationship between entities, the first thing that comes to mind is one to one,one to many and many to many, which are also the most familiar. The author is not proficient in the original concept of ER diagram, but there are three other attributes that can be set in CDM: mandatory (mandatory association), dependent (dependency association / calibration association) and dominant (control association). These attributes have a great impact on the later generation of PDM, and we need to understand them one by one. They are all set in the properties control panel of the contact, as shown in the following figure:

1.mandatory

Whether a connection is mandatory refers to whether such a connection is bound to occur between entities, or in other words, when we are talking about the application scenario of a connection, whether the number of entity instances of the corresponding two entities can be zero. Perhaps this explanation is still a little abstract, let's give two examples of connections, one is mandatory for both entities, and the other is not.

(1) teacher-student contact

This connection is first of all a many-to-many relationship, because each teacher can teach multiple students, and each student has multiple teachers responsible for their studies. At the same time, this connection is mandatory for both teachers and students, that is to say, there is no teacher, he is not responsible for the teaching of any student, and there is no student, he does not have any teacher.

(2) Student-club contact

This connection is also a many-to-many relationship, but it is not mandatory for the physical type of the student (Optional, optional). Every club has at least one student, but not every student has to take part in club activities. It's perfectly possible to have some students who don't join any clubs.

The above example mainly distinguishes mandatory from optional from a conceptual point of view. In fact, if we map this model to our final generated table, if the relation between An and B is mandatory, then if the foreign key of B is included in A, the foreign key cannot be null, otherwise it can be null. You will see this later when we talk about PDM and the actual database.

2.dependent

Each Entitytype has its own Identifier. If an association occurs between two Entitytypes, and the Identifier of one Entitytype enters the other Entitytype and forms its Identifier together with the Identifier in that Entitytype, this association is called calibration association, also called dependency association (dependent relationship). When an Entitytype Identifier enters another Entitytype and acts as its non-Identifier, this association is called an uncalibrated association, also known as an undependent association.

The definition of the concept is still a bit of a mouthful, to put it bluntly, it is actually a master-slave table relationship, and the slave table depends on the master table. For example, in our system to record the situation of teachers' leave, there is an entity Holiday whose attributes include the start time and days of leave. Every time a teacher is on vacation, a record is left in this table. As can be seen from our scenario description, entity holidays must be attached to entity teachers, that is, for each holiday instance, it must point to a teacher instance.

For dependent connections, it must be noted that it cannot be a many-to-many relationship, in which there must be an entity as the subject. A dependent-linked slave entity may not have its own identifier.

3.dominant

This connection attribute is the simplest, it only acts on an one-to-one connection and indicates the master-slave table relationship in this connection. In the relationship between the two entity types of A dominant B, if A-> B is specified as dominant, then An is the master table of the one-to-one relationship, B is the slave table, and a reference is generated in the PDM generated later (two references are generated if the dominant attribute is not specified). For example, the connection between the teacher and the class, because each class has a teacher as the head teacher, each teacher can only be the head teacher of one class at most, so it is an one-to-one relationship. At the same time, we can take the teacher as the main table and use the teacher's job number to determine the only contact with a head teacher.

II. Association (Associated)

Let's first take a look at PD's definition of association: "An association is a connection between entities. In the Merise modeling methodology an association is used to connect several entities that each represents clearly defined objects, but are linked by an event, which may not be so clearly represented by another entity."

For the RelationShip mentioned in the previous paragraph, in many cases (especially in many-to-many relationships), we will specifically mention the connection as an entity type between the two entities that need to be associated (in PD, select any one of the connections, select the "Change to Entity" command in the pop-up menu on the right button to complete the operation of the connection to entity). But sometimes, it may not be appropriate to abstract the relationship between several entity types into a single entity type, at this time you can choose to create an association for these entity types, then when you generate PDM, all these related entity identifier will be added to the table model generated by association. So, to put it bluntly, association is actually a special case of entity type, which is used to express the correlation information between entities more accurately when modeling. In the PD document, it is very accurate that the three entity types of audio tape, customer and store are associated in the scene of renting audio tapes, and then the lease is defined as an example of association between the above three entities. In our school model, I define home visit as an association between teachers and students, and you may see the effect of this definition in the following PDM.

Thank you for your reading, the above is the content of "how to draw ER with powerdesigner". After the study of this article, I believe you have a deeper understanding of how to use powerdesigner to draw ER, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report