当前位置:网站首页>[principles of database system] Chapter 4 advanced database model: Unified Modeling Language UML, object definition language ODL
[principles of database system] Chapter 4 advanced database model: Unified Modeling Language UML, object definition language ODL
2022-07-24 06:05:00 【JKL27】
List of articles
4.7&4.8 Unified modeling language UML
Unified Modeling Language
UML and E/R The correspondence of the graph
| UML | E/R Model |
|---|---|
| class | Entity set |
| relation | Binary connection |
| Association class | Contact properties |
| Subclass | isa level |
| Gather | Many to one contact |
| Combine | Many to one with referential integrity |
UML class And its key
UML Classes and E/R The entity set in the model is similar .
A class box is divided into three parts :
- Top : Class name
- middle : attribute
- Bottom : Method
Specify primary key : After each key attribute, add keyword PK
example :

relation
Definition :
Binary relationships between classes are called associations .
(UML There is no multiple connection , A multiple connection is represented by multiple binary connections )
Associated representation :
In two UML Draw a line between classes , Mark the associated name below the line .
Constraint on the number of objects :
There is a certain constraint on the number of connected objects in the Association class , This constraint is achieved by using a
m..nThe label indicates , At least m individual 、 at most n Objects are connected to objects at the other end .m..*There is no upper limit0..*Indicates that there is no constraint on the number of objects- If there is no label , It's equivalent to
1..1, Indicates that there is and only one .
example :

A representation of referential integrity
See the book P102
Self correlation
Definition :
Both ends of an association can connect the same class , Such association is called self Association (self-association).
To distinguish the different roles of a class in self Association , Give each end of the association a name .
Example :

Association class
The Association class corresponds to E/R In the model , Contact properties
Representation of associated classes :
Put it in the middle of the Correlation , Have your own name , Its attribute is the associated attribute it depends on .
example :

Subclass
Subclass key From the root level .
In subclass , Only record those that are not in the parent class 【 Extra properties 】.
UML Allow a class to have 4 Different subclasses in :
Complete to partial :
Each class C Whether the object of is a member of this subclass ?
yes , Subclasses are complete ;
Otherwise, it is incomplete .
Separate pairs of overlaps :
An object can appear in two subclasses , Subclasses overlap ;
An object cannot be in two subclasses , Subclasses are separate .
Object oriented systems and E/R In the model The type limit of subclasses
characteristic Object oriented system E/R Model Complete or partial ? All allowed All allowed Separate or overlap ? Separate Allow overlap Representation of subclasses :
Point to the parent class with an empty triangle arrow .
example :

Aggregation and combination
Gather
Definition : Represents the many to one relationship between the class and the diamond end class ;
Express :
A line between two classes , The end is an empty diamond , Indicates that the label is
0..1
Combine
Definition : Represents a many to one connection with referential integrity ;
Express : The connection between two classes , The end is a solid black diamond , Indicates that the label is
1..1>
Example :

UML Transformation from graph to relation
class -> Relationship
Create a relationship for each class , The relationship name is the class name , The attribute of the relationship is the attribute of the class .
relation -> Relationship
- summary : Key attributes of two connection classes + Association class ( If any ) Properties of
- For each association, create a relationship with the name associated , The attribute of the relationship is the key attribute of the two connection classes ;
- If there is an associated class attached to the connection , Then the attributes of the relationship should include the attributes of the associated class .
example :

Movies (title, year, length, genre)
Stars (name, address)
Stars-in (movieTitle, movieYear, starName, salary, residuals)
UML Subclass -> Relationship
Three methods :
E/R Method pattern ( The relationship of each subclass has only the key attribute and the subclass attribute )
Object oriented methods ( Each entity is in a subclass relationship )
Null value method ( All subclasses are represented by a relation )
The choice of three methods :
If Each layer is separate , use object-oriented ;
And there is no need to consider every possible subtree , Because each object belongs to only one class and its ancestors .
If Each layer is both complete and separate . With object-oriented, you only need to build relationships for leaf nodes ;
If The layers are large and overlap on some or all layers , Then use E/R Method .
Gather / Combine -> Relationship
Aggregation and combination represent many to one associations , Don't build any relationships for them .
Handle :
hold The key attribute of the class at the diamond end Add to Classes with non diamond ends in .
about Gather , These attributes Can be null ;
about Combine , These attributes Can't be empty .
example :

Transform into the following relationship pattern :
Studios (name, address)
Movies (title, year, length, genre, studioName)
MoviesExecs (cert#, name, address, networth)
Presidents (cert#, studioName)
Weak classes and support combinations -> Relationship
Support combined annotation :
Use a letter “PK” As an anchor supporting composition , It means that the key attribute of the supporting class at the other end of the composition is part of the weak class key .
example :

Transform the above example into a relational pattern :
Studios (name, address)
Crews (number, crewChief, studioName)
4.9&4.10 Object definition language ODL
Object Defination Language
ODL brief introduction
Class declaration
key word
class、 Class name 、 Class feature list .class <name> { <list of properties> };
attribute
- Statement :
attribute Attribute types Property name ; - Attributes can be basic data types or complex types .
contact
Statement :
relationship type Contact name ;Contact type :
For one more : Class name
relationship Studio ownedBy;One to many 、 Many to many : Collection types
relationship Set<Start> stars;
Reverse contact
Reverse relationship They have to come in pairs .
Definition ( Behind the corresponding connection ):
inverse Class name :: Property name ;example :

The multiplicity of connections
ODL in , A pair of mutually opposite connections can be divided into many to one 、 One to one and many to many .
- Two contact statements corresponding to different types are used “Set<>”( many ) and “ Type name ”( One ) Different combinations of ;
- “ many ” It can be “ zero ”, Express “ Any subset ( Including empty sets ) All possible ”
There are two classes C, D,
| C, D The connection between | C The type of corresponding connection in | D in |
|---|---|---|
| Many to many | Set<D> | Set<C> |
| C To D It's many to one | D | Set<C> |
| D To C It's many to one | Set<D> | C |
| one-on-one | D | C |
ODL Data types in
Basic types
Type of atom : integer 、 floating-point 、 Character 、 String type 、 Boolean and enumerative .
Class name : It is actually a structure that contains all the attributes and connections of the class .
Structured model
Collection types
- aggregate (set):
Set<T>, disorder 、 Elements cannot be repeated - package (bag):
Bag<T>, disorder 、 Elements can be repeated {1,2,1} and {2,1,1} It's the same package - list (list):
List<T>, The length can be 0、 Orderly .string namelylist<char>.{1,2,1} and {2,1,1} It's a different list .
- aggregate (set):
Array (array):
Array<T, i>, T Is an atomic type 、 Integers i Length .example :
Array<char,10>Dictionaries (dictionary):
Dictionary<T, S>, Express T,S Finite set of element pairs .
One T Corresponding to one S,T Is the only one. .structure (structure) type
if T1, …, Tn It's the type ,F1, …, Fn Their domain names ,be
Struct N{T1 F1, …, Tn Fn}It's called N The type of structure , contain n Domains , Its first i Types are T i T_i Ti, The domain name is F i F_i Fi.
Contact type
It can be a class , Or apply to a collection of classes 、 Package or list type builder ;
Be careful :
Contact type cannot contain structure type 、 Type of atom . And cannot nest .
The following three are corresponding The wrong sample :
Struct N {Movie field1, Star field2} Set<Integer> Set<Array<Star,10>>
Attribute types
- It can be atomic type or other complex type ;
- You can also use the type builder multiple times to build ;
ODL Subclasses of
The attributes of subclasses consist of :
Inherit all properties of the parent class , And their own attributes .
Statement :
class C extends DMultiple inheritance , Separate categories with colons
class C extends D : Eexample :
class CartoonMurderMystery extends Cartoon : MurderMystery {...};
ODL Declaration of middle key
Statement : Use key perhaps keys( Equivalent ).
Single construction :
class C(keys(attr1, attr2)) {...}Multiple keys :
class C (keys key1, key2, ...)
Contact key
When many to one connections are declared as keys , Indicates **“1” The end can be “ many ” End key **.
example
See the book P113 example 4.54
ODL -> Relationship
Overall approach :
ODL When the attribute in is of non atomic type :
Nonatomic -> atom .
Non atomic types are converted to atomic types in a specific way .
If there is an irregular relationship after transformation , According to Relational schema decomposition Method for optimization
ODL class -> Relationship
Atomic attribute in class :
If all the features in the class are attributes 、 The types of attributes are all atomic types , Then directly transform .
You can create an attribute to express the object identity and make it the key of the corresponding relationship ( Such as id value ).
example :

MovieExecs (cert#, name, address, networth)
Non atomic attribute in class :
Structure type
Define a relationship attribute for each field of the structure , Rename if naming conflicts .
example :

Collection types
For the properties A Set of values for , Construct a tuple for each value in the set , The tuple includes attributes A And the corresponding values of all other attributes in the class .
But there may be irregular relationships ( General violation BCNF), At this time, use the decomposition method to eliminate the exception .
Other types
package : increase count Attribute records the number of occurrences of each tuple in the package .

list : increase position Property indicates the location of the corresponding address in the list .

Fixed length array

Dictionaries : Expressed as a set of two tuples composed of key fields and value fields .

ODL contact -> Relationship
stay ODL in , Relationships appear in pairs opposite to each other ;
For each pair of contacts , Just build a relationship .
Be careful :
- Yes “ For one more ” contact , Connect this contact with In touch “ many ” On the other side of Class to establish a relationship ( That is, two relationships with common keys are combined ), Will not destroy BCNF Conditions .
- Many to one connections cannot be combined “ One ” Fang , Will violate BCNF Conditions .
- Many to many connections cannot be combined .
边栏推荐
- Detailed explanation of KMP code distribution
- [deep learning] teach you to write "handwritten digit recognition neural network" hand in hand, without using any framework, pure numpy
- 树莓派大用处,利用校园网搭建一个校园局域网站
- On the concepts of "input channel" and "output channel" in convolutional neural networks
- Thymeleaf快速入门学习
- 字符串方法以及实例
- 使用Qt连接MySql并创建表号、写入数据、删除数据
- YOLOv5学习总结(持续更新)
- The problem that the user name and password are automatically filled in when Google / Firefox manages the background new account
- Typora installation package in November 2021, the last free version of the installation package to download v13.6.1
猜你喜欢

Answers and analysis of some after-school exercises in signals and systems (Wujing)

jestson安装ibus输入法

【深度学习】手把手教你写“手写数字识别神经网络“,不使用任何框架,纯Numpy
![[USB host] stm32h7 cubemx porting USB host with FreeRTOS to read USB disk, usbh_ Process_ The OS is stuck. There is a value of 0xa5a5a5](/img/be/b7723920f0e81e8699bb26dd1c0fe5.png)
[USB host] stm32h7 cubemx porting USB host with FreeRTOS to read USB disk, usbh_ Process_ The OS is stuck. There is a value of 0xa5a5a5

Delete the weight of the head part of the classification network pre training weight and modify the weight name
![[deep learning] handwritten neural network model preservation](/img/4a/27031f29598564cf585b3af20fe27b.png)
[deep learning] handwritten neural network model preservation

Chapter IV decision tree summary

HAL_Delay()延时误差约1ms的问题

MySQL foundation - constraints

【树莓派4B】七、远程登录树莓派的方法总结XShell,PuTTY,vncServer,Xrdp
随机推荐
Points for attention in adding spp module to the network
Common methods of array
找ArrayList<ArrayList<Double>>中出现次数最多的ArrayList<Double>
day6-jvm
MySQL foundation - constraints
树莓派大用处,利用校园网搭建一个校园局域网站
Deepsort summary
STM32标准外设库(标准库)官网下载方法,附带2021最新标准固件库下载链接
Test whether the label and data set correspond after data enhancement
Machine learning (zhouzhihua) Chapter 5 notes on neural network learning
使用Qt连接MySql并创建表号、写入数据、删除数据
day1-jvm+leetcode
Demo of UDP communication applied to various environments
Accessing a one-dimensional array with a pointer
【数据库系统原理】第四章 高级数据库模型:统一建模语言UML、对象定义语言ODL
Qt新建工程简介
STM32 DSP库MDK VC5\VC6编译错误: 256, (const float64_t *)twiddleCoefF64_256, armBitRevIndexTableF64_256,
CRC-16 Modbus代码
Unicast, multicast, broadcast, tool development, introduction to QT UDP communication protocol development and source code of development tools
The detailed process of connecting MySQL with QT and outputting data to QT window tablewidget.