当前位置:网站首页>关联关系
关联关系
2022-06-11 16:30:00 【peach桃】
关联关系还可以细分为聚合和组合(二者的具体概念读者自行搜索)。
发现聚合、组合可以从另一个角度去理解。
先说说聚合,它是一种弱关联,大概意思就是整体和部分可以独立存在。如果我们换个角度,可以看成是数据库的级联操作。
就拿小组和组员来说,删除某个小组的时候,把该组的组员也删除,这显然是不科学的,因为小组和组员是一种弱关联,小组可以拥有任意一个组员,一个组员也可以去任意一个小组,这个小组不存在了,可以去另一个小组,它们没有必然的关联,可以称为聚合。
因此,我们在设计数据库的时候,往往不会设置级联删除,也就是说,删除小组时不会删除组员。
UML图表示如下:

空心菱形表示聚合,指向one端。
再说说组合,组合是一种强关联,大概意思是整体和部分不可分割,不能独立存在。同样从级联操作理解。
就拿学生和学生证来说,假如某个学生退学,不再属于这个学校,那么可以考虑将该学生信息删除,删除的时候,学生对应的学生证信息也会被删除,在此处可以加级联删除。因为学生证属于某个学生专有的信息,学生不存在了,学生证又不能让他人使用,因此是一种强关联,可以称为组合。
UML图表示如下:

边栏推荐
- 项目经理如何击退被工作汇报支配的恐惧感?
- C语言各数据类型的内存映像
- laravel8 实现签到功能案例
- [ISITDTU 2019]EasyPHP
- solr(二)solr添加core以及依赖包路径
- 数据库全量SQL分析与审计系统性能优化之旅
- The flat life of older farmers from Beijing to Holland
- 时间复杂度与空间复杂度解析
- 时序预测 | MATLAB实现RBF径向基神经网络时间序列未来多步预测
- [learn FPGA programming from scratch -18]: quick start chapter - operation steps 2-6- VerilogHDL sequential circuit syntax analysis (taking the counter as an example)
猜你喜欢

What is a generic? Why use generics? How do I use generics? What about packaging?

项目经理如何击退被工作汇报支配的恐惧感?

pycharm和anaconda的基础上解决Jupyter连接不上Kernel(内核)的问题--解决方案1

2022 safety officer-a certificate test question simulation test question bank simulation test platform operation

Composition of JVM

Student website template brown cake dessert website design - brown cake dessert shop (4 pages) gourmet dessert website production final assignment finished product_ Fresh fruit web design final assign

leetcode463. 岛屿的周长(简单)

leetcode417. Pacific Atlantic current problems (medium)

If you want to learn ArrayList well, it is enough to read this article

基于FPGA的VGA协议实现
随机推荐
Pyqt5 enables the qplaintextedit control to support line number display
RDKit 安装
Pytest测试框架基础篇
Toolbar details of user interface - autorunner automated test tool
What happened to the frequent disconnection of the computer at home
DHCP protocol instantiation analysis
【剑指Offer】21.调整数组顺序使奇数位于偶数前面
Laravel 8 uses passport for auth authentication and token issuance
Laravel 8 realizes database backup through task scheduling
Simulated 100 questions and simulated examination for main principals of hazardous chemical business units in 2022
09 Minimum Spanning Tree highway
CLP Jinxin helps Rizhao bank put into operation its new financial ecological network
laravel 2020-01-01T00:00:00.000000Z 日期转化
时序预测 | MATLAB实现RBF径向基神经网络时间序列未来多步预测
(验证文件)validateJarFile...报错
数据库全量SQL分析与审计系统性能优化之旅
RDKit教程
如何优化 Compose 的性能?通过「底层原理」寻找答案 | 开发者说·DTalk
2022 safety officer-a certificate test question simulation test question bank simulation test platform operation
485 days, 21 experiences of my remote office sharing | community essay solicitation