Goal:
This paper mainly introduces the basic concept of CDM in PowerDesigner conceptual data model.
I. Overview of the conceptual data model
The data model is the abstraction of data features in the real world. The data model should meet three requirements:
1) able to realistically simulate the real world
2) Easy to understand
3) Convenient for computer implementation
The conceptual data model is also called the information model, which is based on the theory of entity-relation (entity-relationship, abbreviation e-r), and expands the theory. It models the information from the user's point of view and is mainly used in the conceptual design of the database.
Often people first abstract the real world into a conceptual world and then turn the conceptual world into a machine world. In other words, the objective object of the real world is abstracted into entity and relation (relationship), it does not depend on the specific computer system or a DBMS, this model is what we call CDM; The CDM is then converted to a data model supported by a DBMS on the computer, which is the physical data model, or PDM.
CDM is a set of strictly defined model elements that accurately describe the static, dynamic, and integrity constraints of the system, including data structure, data manipulation, and integrity constraints.
1) Data structures are expressed as entities and attributes;
2) Data operation is expressed as inserting, deleting, modifying and querying the records in the entity;
3) Integrity constraints are expressed as the integrity constraints (such as data types, checks, rules, etc.) of the data and referential integrity constraints (e.g., contact, inheritance, etc.) between data;
Ii. definition of entities, attributes and identifiers
Entities (entity), also known as instances, correspond to "events" or "things" in the real world that can be distinguished from other objects. For example, every student in the school, every surgery in the hospital.
Each entity has a set of properties that describe an entity's characteristics, called an attribute, and an entity is described by several attributes. If the student entity can be composed by the number, name, gender, date of birth, department, year of entry and other attributes.
An entity set is a collection of specific entities of the same type and of the same nature. For example, a collection of all students in a school can be defined as a "student" entity set, and each entity in the "student" entity has a character such as number, name, gender, date of birth, department, year of entry, etc.
An entity type is a collection of the common properties of each entity in the entity set, such as the "Patient" entity type: Patient {Outpatient number, name, gender, age, social Security number ... }。 An entity is an instance of an entity type, and, in the case of a clear meaning, the entity, entity type is usually used interchangeably.
Each entity in an entity type contains one or a set of properties that uniquely identify it, which is known as an identifier for the entity type (Identifier), such as an identifier for the student entity type, name, date of birth, and address, which together form the identifier for the citizen entity type.
Some entity types can have several sets of properties acting as identifiers, one of which is selected as the primary identifier of the entity type, and the other as the secondary identifier.
Iii. representation of entities, attributes and identifiers
A new concept data model
1) Select File-->new, Pop Up the dialog box, select the CDM model (i.e. conceptual data model) to build the model.
2) Complete the creation of the conceptual data model. To demonstrate, 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 popup menu, and pop up the dialog as shown in the image. The "General" tab allows you to enter the name, code, description, creator, version, and default chart of the model you have built. In the "Notes" tab, you can enter the relevant description and description information. Of course there are more tags, you can click on the "more>>" button, here is no longer explained in detail.
Ii. creation of new entities
1) in the CDM's graphics window, click the Entity tool on the Tools tab, click the Space in the graphics window, and a solid symbol appears where you clicked. Click the Pointer tool or right-click the mouse to release the Entitiy tool.
2) Double-click the entity symbol you just created, open the following icon window, where you can enter the name, code, description, etc. of the entity in the "General" tab of this window.
Third, add entity properties
1) on the "Attribute" tab of the above window, you can add properties as shown in.
Attention:
The features "Add attribute" and "reuse existing data items" in data items are related to the unique code and allow reuse options for data item in the model.
The P column indicates whether the property is the primary identifier, and the D column indicates whether the property is displayed in the graphics window; The M column indicates whether the property is mandatory, that is, whether the column is a null value.
If an entity property is mandatory, then this property must be assigned in each record and cannot be empty.
2) in the window shown, click the Insert Properties button, the Pop-up Properties dialog box, as shown in.
Note: This involves the concept of a domain, a standard data structure that can be applied to the properties of a data item or entity. In the following tutorials, separate chapters will be explained in detail.
Defining a standard check constraint for a property
A standard check constraint is a set of expressions that ensure that a property is valid. In the Properties window of the Entity property, open the Check tab.
In this tab you can define the properties of the standard check constraints, the meaning of the parameters of each item in the window, as follows
Parameters |
Description |
Minimum |
The minimum number of properties that can be accepted |
Maximum |
The maximum number of properties that can be accepted |
Default |
System-supplied default value when the property is not assigned a value |
Unit |
Units, such as kilometers, tons, yuan |
Format |
Data display format for properties |
lowercase |
Property assignment to all lowercase letters |
Uppercase |
The assignment of the property becomes all uppercase |
Cannot modify |
Once the property is assigned, it cannot be modified again |
List of Values |
Property assignment list, except for the values in the list, cannot have other values |
Label |
Label for attribute list value |
Second, additional checks for defining attributes
When standard checks or RULES do not meet the requirements of the check, you can use%minmax%,%listval%,%rules%,%upper%, additional on the server sub-page of the Checks tab in SQL statements, %lower% Several variables to define standard and rule,
%minmax%,%listval%,%upper%,%lower%
Minimum and maximum, list values, uppervalues, lowervalues defined in standard check
%rules%
Validation rule expressions defined in the Expression tab of the Rules Properties window
Goal:
This article mainly describes how to define the primary and secondary identifiers for an entity.
First, identifiers
An identifier is a collection of one or more attributes in an entity that uniquely identifies an instance of an entity. It is emphasized that the identifiers in the CDM are equivalent to the primary key or candidate key in PDM.
Each entity must have at least one identifier. If the entity has only one identifier, it is the primary identifier of the entity. If an entity has more than one identifier, one is specified as the primary identifier, and the remaining identifier is the secondary identifier.
Second, if you define the primary and secondary identifiers
1) Select an entity double-click the pop-up Entity's Properties dialog box. You can define the entity identifiers on the Identifiers tab. As shown
2) Select the first line "main identifier", click the Properties button or double-click the first row "main identifier", Pop Up the properties dialog box,
3) Select the "Attributes" tab, and then click on the "Add Attributes" tool, pop-up window, select a property as an identifier on the line.
Goal:
This article mainly introduces data items, new data items, unique code options for data items, and reuse options.
First, the data item
A data item is the smallest unit of information storage that can be attached to an entity as an attribute of an entity.
Note: Data items that are not attached to any entity are allowed to exist in the model.
Second, new data item
1) Use the "Model"---> Data Items menu to display a list of existing data items in an open window, click the "Add a Row" button to create a new data item,
2) Of course you can continue to set the code, DataType, length, and so on for specific data items. This is not explained in detail here.
Iii. Uniqueness of data Items code options and reuse options
Use tools--->model options->model Settings. In the Data item group box, define the unique code option for the item and the Reuse option (allow reuse).
Attention:
If you select the Unique Code check box, each data item has unique codes in the same namespace, and you choose allow reuse, a data item can act as a property of more than one entity.
Iv. adding data items to Entities
1) Double-click an entity symbol to open the Properties window for that entity.
2) Click the Attributes tab to open the window as shown
Attention:
The difference between Add a DataItem and reuse a DataItem is that
Add A DataItem case, select an already existing data item, 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 copy process, otherwise the data item selected is exactly the same.
Reuse a DataItem case, references are not new, they refer to data items that already exist, as data items for the new entity.
Objective: This article mainly introduces the definition and use of contact.
First, contact
A contact (relationship) is a connection between an entity set or an internal instance of an entity set.
Entities can be interconnected by contact. In correspondence with entity and entity sets, contact can also be divided into contacts and contact sets, which are the links between entity sets, and relations between entities, and linkages are directional. Contact and contact sets can be referred to as connections in the case of a clear meaning.
Depending on the number of instances in the entity type, you can usually divide the contact into 4 categories, one to the other, a-to-many contact, a multiple-to-a (many to a) contact, and many-to-many contacts (many to many).
Ii. Establishment of linkages
In the CDM tool palette, in addition to the common tools, other object generation tools are included as shown.
After you create two entities in the Graphics window, click the Create contact between Entities tool, click an entity, drag the cursor to another entity while holding down the left mouse button, and release the left mouse button, creating a connection between two entities, right-clicking the graphics window, and releasing the relationship tool. As shown
Three or four basic connections
That is, single-to-one contact, a-to-many contact, multi-pair (many to a) contact, and many-to-many contacts (many to many).
Iv. Other types of special links
In addition to the 4 basic links, there is a calibration link (Identify relationship) between the entity set and the entity set, a non-calibrated link (non-identify relationship), and a recursive connection (Recursive relationship).
Calibration Contact:
Each entity type has its own identifier, and if a contact occurs between two entity sets, where an identifier for one of the entity types enters another entity type and forms its identifier together with an identifier in that entity type, this contact is called a calibration contact, also called a dependency relationship. The converse is called non-calibration contact, also called non-dependent connection.
Attention:
In a non-calibrated connection, a partial instance of an entity set relies on an instance in another instance set, in which each entity must have at least one identifier. In a calibration connection, all instances of an entity set depend entirely on an instance in another entity set, in which an entity must have at least one identifier and the other entity may not have its own identifier. An entity that does not have an identifier uses the identifier of the entity it relies on as its own identifier.
In other words, in a calibration connection, an entity (elective course) relies on an entity (student), then the (student) entity must have at least one identifier, and the (elective) entity may not have its own identifier, and an entity without a marked identifier can use the identifier of the entity (student) as its identifier.
Recursive Contact:
A recursive association is a relationship between instances within an entity set, which is often visually referred to as reflexive relationships. Links between different entity sets in the same entity type are also referred to as recursive connections.
For example, there are a lot of workers in the "staff" entity, and there must be a leadership relationship between these workers. And as the entity in the "Student" entity letter contains the "monitor" child entity set and the "normal student" child entity set, the association between the two child entity sets is a recursive association. When you create a recursive contact, you only need to click the Establish contact between entities tool to drag from a part of the entity to the other part of the entity.
V. Defining the characteristics of a relationship
Once you have established a connection between two entities, double-click the contact line to open the Contact Properties window.
Vi. defining the role name of the contact
Each of the two directions in the contact contains a group box, where the parameters only work in this direction, role name is a character, describe the role of the direction of the link, generally with a verb or a dynamic table.
For example, the "Students to subject" group box should be filled in with "owning", and "belong" in the "Lessons to student" group box. (Here is just an example, maybe some words are not very reasonable).
Vii. Mandatory definition of linkages
Mandatory the mandatory relationship between the form and this direction. Select this check box to create a vertical line of contact lines on the contact line. Not selecting this check box indicates that the contact is optional in this direction and a small circle is generated on the contact line.
Viii. base of relevant links
The linkage has directionality, and there is a cardinality in each direction.
Example
The link between "department" and "student" two entities is a one-to-many connection, in other words the link between "student" and "department" is a multi-pair connection. And a student must belong to a department, and can only belong to a department, can not belong to 0 departments, so from the "student" entity to "department" the base of the entity is "a", from the other side of the contact to consider, a department can have more than one student, or no student, that is, 0 students, so the direction of the link , n ",
Cond.
PowerDesigner Database Modeling--conceptual model--er diagram