当前位置:网站首页>Tutorial on principles and applications of database system (009) -- conceptual model and data model
Tutorial on principles and applications of database system (009) -- conceptual model and data model
2022-07-07 12:15:00 【Rsda DBA_ WGX】
Database system principle and Application Tutorial (009)—— Conceptual model and data model
Catalog
The steps to create a database are :(1) Analyze the system requirements according to the real world ;(2) Use conceptual model reality 、 Comprehensively describe the management objects and their connections in the real world ;(3) Transform the conceptual model into something DBMS Supported data models .
The three steps of creating a database correspond to the three worlds of information , namely : Real world , Information world and data world . As shown in the figure below .
One 、 The real world of information
The real world of information is all kinds of things we manage and the connections between things . The real world of information passes through entities 、 Entity set and the relationship between entity sets .
1、 Entity
Things or concepts that can be distinguished from each other in the real world are called entities . Entities can be divided into thing entities and conceptual entities . for example : One of the students 、 A machine 、 A classroom 、 A book is an entity . A course 、 A class is a conceptual entity .
2、 Characteristics of entities
Each entity has its own characteristics , Different entities can be distinguished by using the characteristics of entities . for example : Students can pass the student number 、 full name 、 Gender 、 Age 、 Date of birth 、 height 、 Weight and other characteristics .
An entity has many characteristics , But when we create a database, we will decide which features to save according to the needs of management . For the employees of a unit , If it is based on personnel management , You can choose the job number 、 full name 、 Date of birth 、 position 、 Salary and other characteristics . And if based on the health management of employees , You can choose the job number 、 full name 、 Date of birth 、 height 、 weight 、 Describe blood pressure and other characteristics .
3、 Entity set
A set of entities that have the same characteristics or can be described with the same characteristics is called an entity set . for example : A student is an entity , All students that need to be managed are entity sets . A class is an entity , All classes that need to be managed are entity sets .
4、 The relationship between entity sets
The entity set in the real world is not isolated , There are various connections between entity sets . The relationship between entity sets refers to the corresponding relationship between entities in different entity sets . for example : There is a subordinate relationship between classes and students , There is a relationship between students and courses , There is a teaching relationship between teachers and courses . There are three kinds of relations between two entity sets :
(1) One to one contact (1:1)
There are two entity sets A and B, If the entity set A And entity set B There is a one-to-one connection between , Then for entity set A Every entity in , Entity set B There is at most one entity in ( There can be no ) Connect with it ; conversely , For entity sets B Every entity in , Entity set A At most one entity is associated with it . Entity set A And entity set B The connection between them is expressed as 1:1, for example : The school has a one-to-one relationship with the principal , A school can only have one principal , conversely , A principal can only be the principal of a school . The one-to-one relationship between entity sets is shown in the following figure .
(2) One to many connection (1:n)
There are two entity sets A and B, If the entity set A And entity set B There is a one to many connection between , Then for entity set A Every entity in , Entity set B One or more entities are associated with it ; conversely , For entity sets B Every entity in , Entity set A At most one entity is associated with it . Entity set A And entity set B The connection between them is expressed as 1:n, for example : The class and students have one to many connections , A class can have more than one student , conversely , A student can only study in one class . The one to many relationship between entity sets is shown in the following figure .
(3) Many to many contact (m:n)
There are two entity sets A and B, If the entity set A And entity set B There are many to many connections between , Then for entity set A Every entity in , Entity set B One or more entities are associated with it ; conversely , For entity sets B Every entity in , Entity set A There is also one or more entities associated with it . Entity set A And entity set B The connection between them is expressed as m:n, for example : Students and courses have many to many connections , A student can take more than one course , conversely , A course can be selected by more than one student . The many to many relationship between entity sets is shown in the following figure .
Two 、 Information world and conceptual model
The information world is a description of the real world . In the information world , The characteristics of an entity are called attributes , Entities are represented by attributes as instances , A collection of instances of the same kind is called an object , The relation between entity sets is represented by object relation .
The information world through conceptual models ( Also known as the information model )、 Process model and state model reflect the real world . The conceptual model passes E-R Objects in the diagram 、 Attributes and connections give static descriptions of things and connections in the real world . The process model describes the processing method and information processing process of things through information flow chart and data dictionary . The state model makes a dynamic description of things through the state transition diagram of things .
The database is mainly designed according to the conceptual model , The data processing method is mainly designed according to the process model , The state model has important reference value for the system function design of database .
1、 conceptual model
(1) Instances and objects
Entities are represented by attributes as instances , A collection of instances of the same kind is called an object .
(2) attribute
An attribute is an abstract representation of a feature of an entity . Such as the student's name , Gender , Age is the attribute of students , One of the students' name is Li Ming , Gender is male , Age is 20, Then Li Ming 、 male 、20 Called property values .
(3) Domain
The value range of an attribute is called the field of the attribute . for example : Age range of employees 18—60 Is the domain of age .
(4) code 、 Main code 、 Candidate code
Attributes or attribute groups that can uniquely identify an entity are called codes (key). for example : Student ID is the code of student entity , Because the student ID can uniquely identify the student entity . If an entity has multiple codes , Usually take one of the codes as the main code (primary key), Then the remaining codes are called candidate codes (candidate key).
2、 The representation of conceptual model
have access to E-R chart ( Entity - Contact diagram ) Represent the conceptual model .E-R The graph is also called E-R Model , Provides a set of representation entities 、 Properties and contact methods .
(1) Representation of entity set -
E-R Figure uses a rectangle to represent a set of entities , Write the name of the entity set in the rectangle , As shown in the figure below .
(2) Representation of attributes
E-R Figure uses ellipse to represent the attributes of entity set , And use line segments to connect it with the corresponding entity set , As shown in the figure below .
Because there are many attributes of entity set , Some entities may have dozens or even hundreds of attributes , So in E-R In the figure , The attributes of entity set can not be drawn , Use a data dictionary ( written words ) How to express .
(3) The expression of contact
E-R The diagram uses diamonds to represent the relationship between entity sets , Write the name of the contact in the diamond , And use line segments to connect with the relevant entity set , At the same time, mark the type of connection next to the line segment .
Connections can also have attributes , If the contact has attributes , You need to use line segments to connect attributes and connections . The attribute of the connection must be E-R Mark , Cannot be represented by a data dictionary . Properties in the following figure 【 fraction 】 Just contact 【 Elective 】 Properties of .
3、 ... and 、 Data world and data model of information
Information in the information world , After processing, the data that can be processed by the computer is formed , Is the computer world , Also known as the data world . The related concepts involved in the data world are as follows :
1、 Data item
Data items are data representations of object attributes . Data items can be divided into types and values , The type of data item is the representation of the characteristics of data item , Include the name of the data item 、 data type 、 Data length and field . The value of a data item is its specific value . Such as the student's name , The type of data item can be expressed as : full name , Character , length 20. The value of a student name data item is Zhang Tao .
2、 Record
Records are data representations of instances . There are types and values in records , The type of record is the structure of record , It is composed of data item types . The recorded value represents an instance in the object , The recorded component is the value of the data item . for example :【 full name , Gender , Age , Telephone , Department 】 It is the record type of student data ,【 zhang , male ,20,13783587788, Department of Economics 】 Is the value recorded by a student , Represents an instance of a student object . Of the recorded values 【 zhang 】、【 male 】、【20】、【13783587788】、【 Department of Economics 】 Are the values of data items .
3、 file
A file is a data representation of an object , Is a collection of similar records . The record types in the same file should be the same . for example : Create a data file based on the information of all students , Then the type of each record is the same .
4、 Data model
Data model is the abstraction of data features , The data model is used to represent the record structure and the relationship of records . The most common data includes hierarchical models 、 Mesh model and relational model . Hierarchical models and mesh models are called non relational models .
(1) The three elements of the data model
The data model has a data structure 、 Three elements of data operation and integrity constraints :
A) data structure : What kind of structure is the data stored in the database . hierarchy 、 Reticular structures and relationships ( surface ) The data model of the structure is named hierarchical model 、 Mesh model and relational model .
B) Data manipulation : The data operations that can be carried out in the database mainly include data query and data update ( Insert 、 Delete and modify ), Abbreviation: increase 、 Delete 、 Change 、 check .
C) Data constraints : Data constraints are a set of data integrity rules . Data integrity rules are the constraints and dependency rules of data and its connections in the data model . for example : Entity integrity in relational data model 、 Referential integrity and user-defined integrity . Data constraints are used to ensure the correctness of data in the database 、 Effective and compatible .
(2) hierarchical model
The hierarchical model adopts a hierarchical structure ( Tree structure ) Represents various entities and the connections between entities , The typical representative of hierarchical database system is IBM The company's IMS Database management system .
(3) Mesh model
The mesh model uses a mesh structure to represent various entities and the connections between entities , The typical representative of mesh database system is DBTG System .
(4) relational model
Relational model is the most commonly used data model . Relational models use tables (table) Represents various entities and the connections between entities .
① Related concepts of relationship
A) Relationship : A relationship corresponds to a two-dimensional table .
B) Tuples : A row in the relationship is called a tuple . Some database management systems are called records (record).
C) attribute : A column in a relationship is called an attribute . Some database management systems are called columns (column) Or field (field).
D) code : An attribute or attribute group in a relationship , Their values can uniquely identify a tuple , Such attributes or attribute groups are called relational codes .
E) Domain : The value range of an attribute is called a field .
F) component : The value of an attribute in a tuple is called a component .
G) Relationship model : A relationship pattern is a description of a relationship . The relational schema is expressed as follows :
Relationship name ( attribute 1, attribute 2,……, attribute n)
for example : Student relationship can be expressed as
Student ( Student number , full name , Gender , Date of birth , nation , Political affiliation , Telephone , Department )
② Relationship operation : Relational operations mainly include data query and insertion 、 Delete 、 Modifying data .
③ The integrity constraints of relationships : Entity integrity 、 Referential integrity 、 User-defined integrity .
(5) Comparison between relational model and non relational model
A) The relational data model is based on strict mathematics .
B) The concept of relational data model is single , Easy to understand . In a relational database , Entities and the connections between entities are expressed by relationships .
C) The access path of relational data model is hidden from users . Users operate data according to the logical schema and sub schema of the database , And don't care about the physical mode of the database and the storage of the database in the computer .
D) The data connection in relational data model is through data redundancy ( Outer code ) Realized .
Four 、 The connection between the three worlds of information
The real world of information 、 The relationship between the information world and the data world can be expressed in the following table :
Real world | The information world | Data world |
---|---|---|
Entity | example | Record |
features | attribute | Data item |
Entity set | object | file |
The relationship between entity sets | The connection between objects | The connection between data |
conceptual model | Data model |
The transformation relationship between the three worlds of information is shown in the figure below .
边栏推荐
- PowerShell cs-utf-16le code goes online
- <No. 9> 1805. 字符串中不同整数的数目 (简单)
- 让数字管理好库存
- 盘点JS判断空对象的几大方法
- [extraction des caractéristiques de texture] extraction des caractéristiques de texture de l'image LBP basée sur le mode binaire local de Matlab [y compris le code source de Matlab 1931]
- 什么是局域网域名?如何解析?
- Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
- Up meta - Web3.0 world innovative meta universe financial agreement
- Baidu digital person Du Xiaoxiao responded to netizens' shouts online to meet the Shanghai college entrance examination English composition
- 千人規模互聯網公司研發效能成功之路
猜你喜欢
Fleet tutorial 14 basic introduction to listtile (tutorial includes source code)
[shortest circuit] acwing1128 Messenger: Floyd shortest circuit
全球首堆“玲龙一号”反应堆厂房钢制安全壳上部筒体吊装成功
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
@What happens if bean and @component are used on the same class?
NPC Jincang was invited to participate in the "aerospace 706" I have an appointment with aerospace computer "national Partner Conference
<No. 9> 1805. 字符串中不同整数的数目 (简单)
@Bean与@Component用在同一个类上,会怎么样?
【玩转 RT-Thread】 RT-Thread Studio —— 按键控制电机正反转、蜂鸣器
Up meta - Web3.0 world innovative meta universe financial agreement
随机推荐
牛客网刷题网址
百度数字人度晓晓在线回应网友喊话 应战上海高考英语作文
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
Superscalar processor design yaoyongbin Chapter 10 instruction submission excerpt
Superscalar processor design yaoyongbin Chapter 8 instruction emission excerpt
zero-shot, one-shot和few-shot
Rationaldmis2022 advanced programming macro program
数据库系统原理与应用教程(011)—— 关系数据库
TypeScript 接口继承
[extraction des caractéristiques de texture] extraction des caractéristiques de texture de l'image LBP basée sur le mode binaire local de Matlab [y compris le code source de Matlab 1931]
Flet tutorial 17 basic introduction to card components (tutorial includes source code)
跨域问题解决方案
@What happens if bean and @component are used on the same class?
108.网络安全渗透测试—[权限提升篇6]—[Windows内核溢出提权]
In SQL, I want to set foreign keys. Why is this problem
H3C HCl MPLS layer 2 dedicated line experiment
SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
Detailed explanation of debezium architecture of debezium synchronization
Time bomb inside the software: 0-day log4shell is just the tip of the iceberg
Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)