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

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

边栏推荐
- 时间复杂度与空间复杂度解析
- Ruiji takeout project (III) employee management business development
- 项目经理如何击退被工作汇报支配的恐惧感?
- 用户界面之工具栏详解-AutoRunner自动化测试工具
- 2022 molten welding and thermal cutting work license and simulation examination
- web网页设计实例作业 ——河南美食介绍(4页) web期末作业设计网页_甜品美食大学生网页设计作业成品
- 1267_FreeRTOS启动第一个任务接口prvPortStartFirstTask实现分析
- 2022年危险化学品经营单位主要负责人考试模拟100题及模拟考试
- laravel8 实现签到功能案例
- High concurrency pseudo sharing and cache line filling (cache line alignment) (@contained)
猜你喜欢

What if the win10 security center cannot be closed

Detailed explanation of the functions of list and dict data types

Go quick start of go language (I): the first go program

2022 molten welding and thermal cutting work license and simulation examination

基于ssm框架实现的企业进销存管理系统【源码+数据库+毕设】

leetcode417. Pacific Atlantic current problems (medium)

DHCP protocol instantiation analysis

Customized thread communication (lock) of JUC

从0到1了解Prometheus

C# 启动一个外部exe文件,并传入参数
随机推荐
[sword finger offer] 21 Adjust array order so that odd numbers precede even numbers
laravel 8 使用passport 进行Auth验证及颁发token
one hundred and twenty-three thousand one hundred and twenty-three
jdbc调试错误,求指导
LeetCode——24. 两两交换链表中的节点(三指针)
Project workspace creation steps - Zezhong ar automated test tool
2022 safety officer-a certificate test question simulation test question bank simulation test platform operation
pycharm和anaconda的基础上解决Jupyter连接不上Kernel(内核)的问题--解决方案1
基于ssm框架实现的企业进销存管理系统【源码+数据库+毕设】
cocoapod只更新指定库(不更新索引)
什么是泛型?为什么要使用泛型?泛型怎么用?那包装类呢?
[LeetCode每日一题] |686.重复叠加字符串匹配
Operation guide | how to select a collector on moonbeam and Moonriver
The flat life of older farmers from Beijing to Holland
基于udp端口猜测的内网穿透
[ISITDTU 2019]EasyPHP
[learn FPGA programming from scratch -18]: quick start chapter - operation steps 2-6- VerilogHDL sequential circuit syntax analysis (taking the counter as an example)
2022年安全员-B证国家题库及模拟考试
Regression prediction | realization of RBF RBF neural network with multiple inputs and single output by MATLAB
High concurrency pseudo sharing and cache line filling (cache line alignment) (@contained)