270. Data Model

1. Three types of data models

 

Ø  logical model of data and its associated objective things described, comprises a mesh model, hierarchical model, the relational model and the object-oriented model and the like, which is to model the concept of computer systems, mainly used to implement the DBMS .

Ø  conceptual model also known as the information model , the result is to be modeled on the data and information from the user's view, mainly for database design .

Ø  physical model is a bottom abstract data described in the data for the representation of and access to the internal computer system , which is implemented by a complete DBMS.

  The two main functions of the data model for describing data and its relevance. It consists of three basic elements, i.e. a data structure, data constraints and data operations.

 

2. The basic elements of the data model

2.1 Data Structure

Definition: static characterization data, which is a collection of object type being studied.

classification:

Ø describe data objects

• Definition: The property of the object for the associated description data, content type, and the like

• Identify key objects contained, and items named, pointed out that the data type and value range and other items.

Ø data describing the relationship between objects

• Definition: an object is used to describe the relationship between information data

• specify the nature of relationships and the relationships between different object types, and naming these relationships.


 

2.2 data manipulation

Definition: used to describe the dynamic characteristics of the data, which is a collection of all the operations and related operating rules of the database instances of the various object types permitted to execute.

classification:

Ø inquiry

Ø Update

• update also includes insertions, deletions, and modifications.

  In the data model, each attribute defined to clear the operation, such as operators, operating rules implemented in language and the like.

 

Data constraints 2.3

   Constraint is a collection of data integrity rules. Integrity rule refers to the established data model data and its relationship with a conditionality rules and dependency rules. These rules are defined by a method in line with the state database and data model changes to ensure the accuracy, effectiveness and compatibility data.

 

2.4 Role of the three elements

  The data structure is the basis, it determines the nature of the data model.

  Data manipulation is the key, which determines the dynamic properties of the data model.

  The main constraints play a supporting role.

 

 

 

3. The four main logic model

3.1 hierarchical model

  To organize the data tree structure, its data structure is the root of the tree

  Features:

Ø there is only one node has no parent, the root node is the root of the tree.

Ø In addition to the root, and the other node has only one parent node, but may be provided by zero or more child nodes.

 

  Child nodes in a hierarchical model, having the same parent are called siblings, no child node is called a leaf node.

  In the hierarchy of the root of the tree, each node represents an entity type. However, since the hierarchical model entity type is represented in the record type, the root of the tree each node actually represents a record type. Since each record type node has only one parent node (except the root node), so long as each node indicated its parent, it shows a data structure can be hierarchical model. If you want to access a particular record type node, you can use the associated root tree traversal method to find that starting from the root node, and then access it.

 [Example] a school contains multiple Academy, a college and contain multiple lines and institutes. In this way, schools, colleges, and research institutes such as the Department entity constitutes a very natural hierarchy in the real world. Hierarchical model described precisely in order to meet the needs of such a hierarchical relationship arising. So, it's natural expression, intuitive, but its disadvantages are also obvious.

 As shown in the example of FIG data for a hierarchical model tissue of school.

Examples of a school organized by hierarchical model data

 

 

Hierarchical model Disadvantages:

• Process inefficiencies

Ø This is because the data structure is a hierarchical model tree root access to any node must start from the root. This makes access to the bottom node efficiency becomes low, and it is difficult for a reverse lookup.

• Difficult to update operation

Ø update operations include insert, update and delete operations. When a node of a tree for such update operation, are likely to lead to large changes in Zhengke root of the tree. For large data sets, this is a heavy.

• Security is not good

Ø This is mainly reflected in, when you delete a node, its children and grandchildren nodes are removed. Therefore, we must caution deletion.

• poor data independence

Ø When manipulating data in a hierarchical order, which requires knowledge of the physical structure of the user data, and need to be explicit access route.

 

 

3.2 Network Model

  Network Model: each data is represented by a node, each node has links with other nodes, so that all the data in the node database constitutes a complex network. Figure 1.3 is an example of data organized in a mesh model shown in FIG.

1.3 exemplary data organized in a mesh model of FIG.

 

  Mesh model of the data structure is a mesh structure. Mesh model reflects the real-world entities more complex linkages. As can be seen from the following features, there is no clear relationship between the slave node, a node can have more contact with other nodes.

  Feature

Ø permits more than one node has no parent.

Ø node can have more than one parent.

  Disadvantages:

When using a mesh Ø Since the model, the user must be familiar with the logical structure of the data, the complexity of the structure and increases the difficulty of locating the user query.

Ø not express support for hierarchy and so on.

Ø hierarchical model with similar, each node represents a physical network structure of the type, and this type of entity type is represented in the record. And the hierarchy is different: there is one and only one root node in the hierarchy, in the network structure allows multiple "root" at the same time; and each node has only one parent node in the hierarchy (except the root node) in the network structure of a node is allowed to have multiple "parent."

Ø difference in this configuration, also led to changes in the structure of the recording type corresponding to the node. Achieve inter-node network model in contact it must be pointed out that while the method of its parent node and child nodes to complete. In the hierarchical model, each node can simply specify its parent node (except the root node). It is precisely because of this difference, so that the mesh model occurs a significant change in the nature and function. This is mainly reflected in: the mesh model with greater flexibility and greater data modeling capabilities than the hierarchical model.

 

[Examples] Figure 1.8 shows a diagram of a network structure elective link between students A, B and program C, D, E.

 

  For the small amount of data, the shortcomings of the hierarchical model and the network model may not be obvious, but when used as a large amount of data, the drawback is very prominent. Therefore, these two models are not suitable for today to process massive amounts of data is characterized by data processing tasks. Currently, they are basically out of the market, replaced by the relational model.

 

 

3.3 Relational Model

3.3.1 definitions

  Relational model: a two-dimensional table (table) in the form of organizational data in the database

  The relational model is one of today's most popular data model. In the relational model, the links between entities are defined by two-dimensional relationship (referred to as relations), its data structure is two-dimensional relationship. A two-dimensional relationship of each can be used to represent a two-dimensional table, expressed intuitive and clear. So, very often the two-dimensional tables and relationships directly equated, for short (two-dimensional) table. The relational model is a collection of several sheets of relational tables.

 

  For example, students involved in student performance management system, curriculum and grades three tables. The main student information table covered are school number, name, sex, date of birth, professional, total credits, notes. The main information related to the curriculum has course number, course name, Semester, hours and credits. The main achievement information table covered are student number, course number and achievements. Table 1.1, Table 1.2 and Table 1.3 describes the part of the data management system middle school student achievement, curriculum and achievements of these three tables, respectively.

Table 1.1 Student table

 

Students, courses, grades, three objects

Tables may be entities may be many relationship

Table 1.2 curriculum

Table 1.3 results table

 

For example, Table 1.1 in the "study" can uniquely identify each student , Table 1.2 in the "program number" that can uniquely identify each course . Table 1.3 in the "study" and "course number" that can uniquely identify each student a score of course.
Sometimes, a table may have multiple codes, such as Table 1.1, the names are not allowed the same name, the "study", "name" are student information table code. For each table, a code can be specified generally as "Major", in the relational model, typically underlined master code.
Table 1.1 set the name for the XSB, relational schema can be expressed as XSB (student number, name, sex, date of birth, professional, total credits, notes).
Table 1.2 is set name KCB, relational schema can be represented as KCB (course number, course name, Semester, hours, credits).
Table 1.3 set name for CJB, relational schema can be expressed as CJB (student number, course number, grades, credits).

 

 

3.3.2 The term relational model

Ø relationship: a two-dimensional table.

Ø recording (or component): a relational table row.

Ø fields (or attributes): a relational table.

Ø domain: That field range, that is, the range of the field.

Ø data items (or components): a value for a field in a record.

Ø primary key field (or master code): referred to as the primary key, a set of relational tables or a plurality of fields, the values ​​of these records can uniquely identify each record.

Ø relational schema: an abstract description of the relationship, which is described in the format "name relation (Field 1, Field 2, ..., n-Field)", where "Field 1" underlined indicates that the field is a primary key segment.

 

Features 3.3.3 relational model

• A rigorous mathematical foundation. Relational algebra, relational calculus and so can be used to model the relationship between the qualitative or quantitative analysis to explore the relationship of combined separation and the like and its related properties.

• The concept of a single, intuitive expression, but with a strong expression data and modeling capabilities. In general, a relationship only express a theme, if there are multiple topics together, you need to separate them, with multiple relationships to represent, this is the concept of a single.

• relations have been standardized. That relationship to meet certain specifications conditions, which makes the relational model show some unique properties.

Ø For example, the data entry in a relational data unit is the most basic, it can not be decomposed; have the same data type field of the same field value; arbitrary order of each field is sequentially recorded is arbitrary, and the like .

• In the relational model, the operation of the data is a collection of operations, i.e., the operation target is a collection of records, generated by the operation result is a collection of records. This operation has no clear direction, no matter how, the degree of difficulty are the same. In the hierarchical model and the mesh model of the operation of the data with a clear directionality in both directions difficulty of completely different operations.

 

 

3.3.4 disadvantage of relational model

Ø poor ability to model complex problems. When modeling complex problems usually exhibit complex relationship, and the relational model is limited to two-dimensional relationship to represent these complex relationships, it can not be described by a recursive and nested way (because it does not allow nested and embedded recording there is set relationship). So, in many cases the relational model appeared to be inadequate.

Ø expression semantic objects relatively poor. The real world, relationships between objects is often not limited to the relationship between the amount, but also may reflect the link between semantics implies a specific meaning. But for the standardization of relational model these relationships may be forced to open this semantic connection, resulting in unnatural decomposition, so that the results appear unreasonable semantic query and other operations.

Ø poor scalability. Relational model which only supports a collection of records, a data structure and the data item can not be divided, the recording can not be formed and nested nesting relationship, so it can not be expanded into a mesh or hierarchical model model. And it does not support abstract data types, various types of data objects can not be managed.

 

 

3.4 object-oriented model

  Object-oriented methods (Object-Oriented Paradigm, referred to as OO) basic starting point is the method and way of thinking human understanding of the world to analyze and solve problems.

  Object-oriented model is a data model for modeling and object-oriented method of representing formed.

  Theories and methods of object-oriented model is not mature enough, mainly in theoretical research and experimental stage.

 

 

4. Description of Conceptual Model

4.1 Conceptual Model

  From the modeling data model, the general is the first real-world problems modeled as a conceptual model in the world of information, then the conceptual model in the world of information into a logical model of the machine world.

  When the confirmation conceptual model has been able to fully express the original problem (real world) time, then this conceptual model into a data model of a database system in a given DBMS support to form a logical model of the machine world.

  From the real world to the world of machine conversion process can be expressed in Figure 1.9.

 

 

4.2 and its associated entities

1. Concept

Entity is and can be distinguished from each other Everything that exists objectively.

Properties of an entity refers to the entity having the characteristics.

Ø eg: the student is an entity, such as name, gender, performance, etc. are attributes of the entity.

Code , also known as keywords , it is a collection of one or more attributes.

Ø eg: Student ID is a code of student entity.

Domain property means a property of value ranges.

Ø eg: student achievement is the domain entity.

Entity type is the name refers to a collection of entities and entity attributes common name to describe the same type of entity.

Ø eg: Student (Student ID, name, sex, place of birth, achievement) is an entity type.

Entity set is a collection of entities.

 

contact

Ø definitions

• refers to the relationship between things (the real world) is reflected in the information world.

Ø Two types

• Internal link between physical contact and entities.

Ø three kinds of contact types

Suppose that A and B represent the two entities set

• Contact one denoted by (1: 1).

• Contact recorded as many (1: n).

• many to many links denoted by (m: n).

 

When the real problems in the real world into a conceptual model of the information world, what this conceptual model to describe it?

When the database theory, usually the ER diagram to describe the conceptual model, which provides a representation of the entity type, properties and methods of contact.

 

4.3 Design concept  

实体集中的实体彼此是可区别的。如果实体集中的属性或最小属性组合的值能唯一标识其对应实体,则将该属性或属性组合称为码。对于每一个实体集,可指定一个码为主码。
  如果用矩形框表示实体集,用带半圆的矩形框表示属性,用线段连接实体集与属性,当一个属性或属性组合指定为主码时,在实体集与属性的连接线上标记一斜线,则可以用图1.4描述学生成绩管理系统中的实体集及每个实体集涉及的属性。

 

 \主键

 

 

 

 

4.3.1 E-R图

1.实体及其属性的表示

【例子】 对于一个实体型——学生(学号,姓名,成绩),其E-R图如图1.10所示。

 

注意:实体图ER图可以分开

 

 

2.实体型之间联系的表示

  两个实体型之间联系的表示

 

  多个实体型(三个或三个以上)之间联系的表示

Ø 三个实体型A、B、C之间联系表示为(m:n:o),其中m,n,o > 0。

【例子】 对于供应商、仓库和零件,由于一个供应商可以提供多种零件并存放在不同仓库中,而一种零件也可以由多个供应商提供并存放在不同仓库中,同时一个仓库也可以存放不同供应商提供的多种零件。所以供应商、仓库和零件之间的联系是多对多联系,其E-R图可以用图1.12表示。

 


 

3.实体型内部联系的表示

  同一个实体型内部实体的三种联系对应的E-R图,分别如图1.13的(a)、(b)和(c)所示。

 

 

【例子】 职工实体型中的实体具有领导与被领导的联系,这种联系是一对多联系,可以用图1.14表示。

 

4.联系属性的表示

  联系的属性的表示方法与实体的类似

Ø 对于供应商和仓库之间的联系(库存),其属性(库存量),可以表示如图1.15所示。

 

 

总结

  利用实体、属性和联系及其之间关系的表示方法可以将现实世界中的复杂问题抽象成为信息世界中的概念模型。

  概念模型通常是用E-R图表示的,E-R图的设计过程就是对问题进行抽象和建模的过程。

 

Guess you like

Origin www.cnblogs.com/ZanderZhao/p/11494139.html