Transfer http://www.cnblogs.com/liuxiuhao/archive/2012/04/18/2455107.html
1. Conceptual Data Model Overview
Data models are the abstraction of data features in the real world. The data model must meet the following requirements:
1) Ability to simulate the real world more realistically
2) easy to understand
3) easy to implement by Computer
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 static characteristics, dynamic characteristics, and integrity constraints of the system, it consists of three parts: data structure, data operation, and integrity constraint.
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
This section describes how to create a PowerDesigner data model, an object, and an attribute.
1. 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 tab, you can enter the name, code, description, creator, version, and default chart of the created model. Enter the description and description in the "Notes" tab. For More tags, click "More>.
2. Create a new 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.
3. 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. 2) In the displayed window, click the insert attribute button to bring up the attribute dialog box, as shown in.
Note: This involves the concept of a domain, that is, a standard data structure, which can be applied to the attributes of data items or entities.
I. Define standard inspection constraints for Attributes
The standard check constraint is 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:
Parameter description: Minimum acceptable value of the Minimum attribute when the Maximum number of acceptable values of the Maximum attribute Default attribute is not assigned a value, the Default Unit provided by the system, for example, the value assignment Of the Lowercase attribute in the data display Format Of the kilometer, Ton, and Yuan Format attribute is changed to the value assignment Of the lower case letter Uppercase attribute, and all the Values are changed to the upper case letter Cannot modify. Once the value assignment Of this attribute Cannot be modified List attribute assignment list, except the values in the list, there cannot be tags of other values in the Label attribute list.
Ii. Additional inspection of defining attributes
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
1. 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.
2. If the Primary and Secondary identifiers are defined
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.
I. 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.
2. 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.
Iii. 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.
4. 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.
1. 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 ).2. Establish contacts
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
3. Four basic connections
That is, ONE-TO-ONE connections, ONE-TO-MANY connections, ONE-TO-ONE connections, and MANY-TO-MANY connections ).
4. 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, there are many employees in the "employees" entity, and there must be a relationship between the leaders and the leaders. Another example is that the entity in the "student" entity contains the "class monitor" and "common student" child body sets. The link between the two child body 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.
5. define the characteristics of contact
After establishing a contact between the two entities, double-click the contact line to open the contact feature window ,.
6. Define the role name of the contact
There is a grouping box in each of the two directions of the contact. The parameter takes effect only in this direction, and the Role Name is the Role Name, which describes the Role of the contact in this direction, generally, a verb or a dynamic object group table is used.
For example, in the "student to course" group box, enter "own", and in the "course To student" group box, enter "Belong ". (Here is just an example to illustrate that some words may be inappropriate ).
VII. Define mandatory contact
The Mandatory relationship of the Mandatory table in this direction. Select this check box to generate a vertical line on the contact line. If this check box is not selected, the contact direction is optional. A small circle is generated on the contact line.
8. Contact Base
The connection is oriented and each direction has a base.
For example,
The relationship between the "department" and "student" entities is one-to-many. In other words, the relationship between "student" and "department" is one-to-one. In addition, a student must belong to only one department and cannot belong to none. Therefore, the base from "student" to "department" is ", in another direction of contact, a department can have multiple students, or no student, that is, zero students. Therefore, the base of contact in this direction is "0, n ",
CDM is the first model created by most developers when using PD, and is also the highest abstraction of the entire database design. CDM is built on the traditional ERTU model theory. ERTU has three main elements: entity type, attributes, and relationships. The Entity type corresponds to the Entity in the CDM, and the Attribute corresponds to the Attribute of each Entity in the CDM, which is basically one-to-one in concept. However, in terms of contact, CDM has a relatively large extension. In addition to retaining the original RelationShip concept of ERTU, It also adds the associations and Inheritance entities, next let's take a look at the usage of these relationships and their differences (the highlighted toolbar button is used to add these relationships to the object ).
In addition, before introducing all the elements in CDM, the author first gives a very simple CDM diagram, which is a modeling of the most familiar school scenario, all the concepts mentioned below are embodied in the graph. You can refer to them as follows:
1. RelationShip (contact)
First, the PD Manual defines the contact: "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. "Obviously, maybe the concept of contact is too simple, so it is not so easy to express, therefore, the PD document uses an example to describe what happens. We think there is a relationship between two entities.
When we talk about the relationship between entities, I am afraid the first three contact types are one to one, one to one, and two to others. These contact types are also the most familiar ones. I am not familiar with the original concepts of ERTU, but in CDM, there are three other properties that can be set: mandatory (mandatory contact) and dependent (dependency contact/calibration Association) and dominant ). These attributes have a great impact on the subsequent production of PDM, so we need to know them one by one. They are all set in the contact property control panel, see:
1. mandatory
Whether a connection is mandatory means whether such a connection is inevitable between entities. Or, in other words, when we talk about an application scenario of a connection, the number of physical instances corresponding to the two physical instances cannot be zero. Perhaps this explanation is a bit abstract. Let's give two examples of the link. One is mandatory for both entities, and the other is not.
(1) Instructor-student contact
This contact is one-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 contact is mandatory for both teachers and students. That is to say, if no teacher exists, he is not responsible for the teaching of any student. No student exists, he does not have any instructors.
(2) Student-contact the club
This relationship is also a many-to-many relationship, but it is not mandatory for the student's real shape (Optional, Optional ). Each club has at least one student, but not every student is going to participate in club activities. There may be some students who are not involved in any club.
The above example mainly distinguishes mandatory from optional from a conceptual perspective. In fact, if we map this model to the table we finally generated, if the connection between the A-B is mandatory for A, if in A contains the foreign key of B, this foreign key cannot be a null value. Otherwise, it can be a null value. We will see this later when talking about PDM and the actual database.
2. dependent
Each Entity type has its own Identifier. If two Entity types are associated, when one Entity-type Identifier enters another Entity-type and forms its Identifier together with the Identifier in this Entity-type, this association is called a calibration Association, also called a dependent relationship ). When an Entity-type Identifier enters another Entity-type and acts as its non-Identifier, this association is called a non-standard association or non-dependent association.
The definition of the concept is still a bit writable. To put it bluntly, it is actually a master-slave table relationship, and the slave table depends on the master table. For example, we want to record the instructor vacation situation in our system. There is a real-life Holiday. Its attributes include the start time and number of days of vacation, all records must be left in this table. From our scenario description, we can see that a real-person holiday must be attached to a real-person instructor, that is, for each vacation instance, it must point to a certain instructor instance.
For dependency-dependent connections, you must note that it cannot be a many-to-many relationship. In this connection, there must be a real body type as the subject. The slave entity associated with a dependent may not have its own identifier.
3. dominant
This contact property is the simplest. It only applies to one-to-one connections and specifies the master-slave table relationship in the connection. In the relationship between A and B, if A --> B is specified as dominant, A is the one-to-one master table and B is the slave table, in addition, a reference will be generated in the PDM generated later (if the dominant attribute is not specified, two references will be generated ). For example, the relationship between the teacher and the class, because each class has a teacher as the class teacher, each teacher can only be a class teacher at most, so it is a one-to-one relationship. At the same time, we can take the teacher as the master table and use the teacher's employee ID to uniquely identify a class teacher's contact.
2. Association)
Let's take a look at the definition of PD for 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. ".
In the RelationShip mentioned in the previous section, in many cases (especially in many-to-many relationships), we will specifically propose the contact, place a solid shape in the middle of two entities to be associated (in PD, select any link, right-click the pop-up menu and select the "Change to Entity" command to complete the contact to object operation ). However, it may be inappropriate to abstract the links between several geometries into one. In this case, you can choose to create an association for these geometries. When PDM is generated, all the identifiers related to these entities will be added to the table model generated by association. So, to put it bluntly, association is a special case of real-world entities. It is used to more accurately express the association information between entities during modeling. In the PD document, three real types of tapes, customers, and stores are associated in the scenario of renting tapes. Then, the rent is defined as an example of association between the above three real types, very accurate. In our school model, I defined home visits as an association between teachers and students. In the subsequent PDM, you may see the effect of this definition.
Iii. Inheritance (Inheritance)
This relationship is the easiest to understand at the conceptual level. This article will not go into detail.
We have already introduced the main content about the relationship between entities in CDM. Next we will look at what PDM is generated based on this CDM: click TOOLS generate physical model or ctrl + shift + p. OK.
1. Conceptual Data Model Overview
Data models are the abstraction of data features in the real world. The data model must meet the following requirements:
1) Ability to simulate the real world more realistically
2) easy to understand
3) easy to implement by Computer
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 static characteristics, dynamic characteristics, and integrity constraints of the system, it consists of three parts: data structure, data operation, and integrity constraint.
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
This section describes how to create a PowerDesigner data model, an object, and an attribute.
1. 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 tab, you can enter the name, code, description, creator, version, and default chart of the created model. Enter the description and description in the "Notes" tab. For More tags, click "More>.
2. Create a new 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.
3. 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. 2) In the displayed window, click the insert attribute button to bring up the attribute dialog box, as shown in.
Note: This involves the concept of a domain, that is, a standard data structure, which can be applied to the attributes of data items or entities.
I. Define standard inspection constraints for Attributes
The standard check constraint is 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:
Parameter description: Minimum acceptable value of the Minimum attribute when the Maximum number of acceptable values of the Maximum attribute Default attribute is not assigned a value, the Default Unit provided by the system, for example, the value assignment Of the Lowercase attribute in the data display Format Of the kilometer, Ton, and Yuan Format attribute is changed to the value assignment Of the lower case letter Uppercase attribute, and all the Values are changed to the upper case letter Cannot modify. Once the value assignment Of this attribute Cannot be modified List attribute assignment list, except the values in the list, there cannot be tags of other values in the Label attribute list.
Ii. Additional inspection of defining attributes
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
1. 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.
2. If the Primary and Secondary identifiers are defined
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.
I. 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.
2. 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.
Iii. 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.
4. 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.
1. 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 ).2. Establish contacts
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
3. Four basic connections
That is, ONE-TO-ONE connections, ONE-TO-MANY connections, ONE-TO-ONE connections, and MANY-TO-MANY connections ).
4. 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, there are many employees in the "employees" entity, and there must be a relationship between the leaders and the leaders. Another example is that the entity in the "student" entity contains the "class monitor" and "common student" child body sets. The link between the two child body 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.
5. define the characteristics of contact
After establishing a contact between the two entities, double-click the contact line to open the contact feature window ,.
6. Define the role name of the contact
There is a grouping box in each of the two directions of the contact. The parameter takes effect only in this direction, and the Role Name is the Role Name, which describes the Role of the contact in this direction, generally, a verb or a dynamic object group table is used.
For example, in the "student to course" group box, enter "own", and in the "course To student" group box, enter "Belong ". (Here is just an example to illustrate that some words may be inappropriate ).
VII. Define mandatory contact
The Mandatory relationship of the Mandatory table in this direction. Select this check box to generate a vertical line on the contact line. If this check box is not selected, the contact direction is optional. A small circle is generated on the contact line.
8. Contact Base
The connection is oriented and each direction has a base.
For example,
The relationship between the "department" and "student" entities is one-to-many. In other words, the relationship between "student" and "department" is one-to-one. In addition, a student must belong to only one department and cannot belong to none. Therefore, the base from "student" to "department" is ", in another direction of contact, a department can have multiple students, or no student, that is, zero students. Therefore, the base of contact in this direction is "0, n ",
CDM is the first model created by most developers when using PD, and is also the highest abstraction of the entire database design. CDM is built on the traditional ERTU model theory. ERTU has three main elements: entity type, attributes, and relationships. The Entity type corresponds to the Entity in the CDM, and the Attribute corresponds to the Attribute of each Entity in the CDM, which is basically one-to-one in concept. However, in terms of contact, CDM has a relatively large extension. In addition to retaining the original RelationShip concept of ERTU, It also adds the associations and Inheritance entities, next let's take a look at the usage of these relationships and their differences (the highlighted toolbar button is used to add these relationships to the object ).
In addition, before introducing all the elements in CDM, the author first gives a very simple CDM diagram, which is a modeling of the most familiar school scenario, all the concepts mentioned below are embodied in the graph. You can refer to them as follows:
1. RelationShip (contact)
First, the PD Manual defines the contact: "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. "Obviously, maybe the concept of contact is too simple, so it is not so easy to express, therefore, the PD document uses an example to describe what happens. We think there is a relationship between two entities.
When we talk about the relationship between entities, I am afraid the first three contact types are one to one, one to one, and two to others. These contact types are also the most familiar ones. I am not familiar with the original concepts of ERTU, but in CDM, there are three other properties that can be set: mandatory (mandatory contact) and dependent (dependency contact/calibration Association) and dominant ). These attributes have a great impact on the subsequent production of PDM, so we need to know them one by one. They are all set in the contact property control panel, see:
1. mandatory
Whether a connection is mandatory means whether such a connection is inevitable between entities. Or, in other words, when we talk about an application scenario of a connection, the number of physical instances corresponding to the two physical instances cannot be zero. Perhaps this explanation is a bit abstract. Let's give two examples of the link. One is mandatory for both entities, and the other is not.
(1) Instructor-student contact
This contact is one-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 contact is mandatory for both teachers and students. That is to say, if no teacher exists, he is not responsible for the teaching of any student. No student exists, he does not have any instructors.
(2) Student-contact the club
This relationship is also a many-to-many relationship, but it is not mandatory for the student's real shape (Optional, Optional ). Each club has at least one student, but not every student is going to participate in club activities. There may be some students who are not involved in any club.
The above example mainly distinguishes mandatory from optional from a conceptual perspective. In fact, if we map this model to the table we finally generated, if the connection between the A-B is mandatory for A, if in A contains the foreign key of B, this foreign key cannot be a null value. Otherwise, it can be a null value. We will see this later when talking about PDM and the actual database.
2. dependent
Each Entity type has its own Identifier. If two Entity types are associated, when one Entity-type Identifier enters another Entity-type and forms its Identifier together with the Identifier in this Entity-type, this association is called a calibration Association, also called a dependent relationship ). When an Entity-type Identifier enters another Entity-type and acts as its non-Identifier, this association is called a non-standard association or non-dependent association.
The definition of the concept is still a bit writable. To put it bluntly, it is actually a master-slave table relationship, and the slave table depends on the master table. For example, we want to record the instructor vacation situation in our system. There is a real-life Holiday. Its attributes include the start time and number of days of vacation, all records must be left in this table. From our scenario description, we can see that a real-person holiday must be attached to a real-person instructor, that is, for each vacation instance, it must point to a certain instructor instance.
For dependency-dependent connections, you must note that it cannot be a many-to-many relationship. In this connection, there must be a real body type as the subject. The slave entity associated with a dependent may not have its own identifier.
3. dominant
This contact property is the simplest. It only applies to one-to-one connections and specifies the master-slave table relationship in the connection. In the relationship between A and B, if A --> B is specified as dominant, A is the one-to-one master table and B is the slave table, in addition, a reference will be generated in the PDM generated later (if the dominant attribute is not specified, two references will be generated ). For example, the relationship between the teacher and the class, because each class has a teacher as the class teacher, each teacher can only be a class teacher at most, so it is a one-to-one relationship. At the same time, we can take the teacher as the master table and use the teacher's employee ID to uniquely identify a class teacher's contact.
2. Association)
Let's take a look at the definition of PD for 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. ".
In the RelationShip mentioned in the previous section, in many cases (especially in many-to-many relationships), we will specifically propose the contact, place a solid shape in the middle of two entities to be associated (in PD, select any link, right-click the pop-up menu and select the "Change to Entity" command to complete the contact to object operation ). However, it may be inappropriate to abstract the links between several geometries into one. In this case, you can choose to create an association for these geometries. When PDM is generated, all the identifiers related to these entities will be added to the table model generated by association. So, to put it bluntly, association is a special case of real-world entities. It is used to more accurately express the association information between entities during modeling. In the PD document, three real types of tapes, customers, and stores are associated in the scenario of renting tapes. Then, the rent is defined as an example of association between the above three real types, very accurate. In our school model, I defined home visits as an association between teachers and students. In the subsequent PDM, you may see the effect of this definition.
Iii. Inheritance (Inheritance)
This relationship is the easiest to understand at the conceptual level. This article will not go into detail.
We have already introduced the main content about the relationship between entities in CDM. Next we will look at what PDM is generated based on this CDM: click TOOLS generate physical model or ctrl + shift + p. OK.