当前位置:网站首页>TYUT太原理工大学2022数据库大题之E-R图转关系模式
TYUT太原理工大学2022数据库大题之E-R图转关系模式
2022-07-06 09:19:00 【啦啦噜噜^_^】
题型一
这类题较简单;我们还是先了解题中可能出现得各名词含义,然后看几道例题把它学会
一、
1、E-R图构成:(1)长方形——实体(2) 椭圆——属性(3)菱形——关系
二、
1、主键:主键就是能够唯一标识表中某一行的属性或属性组(这个东西很好找,不教啦)
2、主键和主码的区别:(一般不做区分,当成一种东西)
一个表只能有一个主键,但可以有多个候选索引,当有多个候选码时,可以选定一个作为主码,选定的候选码称主键,而主码可以有多个
3、外键:通过一个表的外键可以关联到另一个表,从而定义出一对多关系或多对多关系
4、一个属性或者一组属性可以既是主键又是外键
5、关系模式:简记为R(A1,A2,~~~An),R为关系名,A为属性名
三、方法(先写长方形,再写菱形,写完后确认一对一中的难点是否出现,主键写在前面)
E-R模型如何转换成关系模型,这里分成三种情况进行讲解,分别是一对一,一对多和多对多。(因为有两种方法,所以往往这种题答案不唯一,我这里只介绍最简单的!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
1.一对一的情况:
(1)将所有实体(即长方形)及其相对应的属性(指向实体的椭圆)以关模式 R (A1,A2,~~~An)的形式依次列出;
(2)再将关系(菱形)及其对应实体的主码和菱形本身属性以关系模式R(A1,A2,~~~An)的形 式依次列出,其中关系对应R,主码对应A,任意主码都可以作为此关系模式的主键
(3)难点:此难点放到例题中讲,很重要,是该题满分的关键
2.一对多的情况:
(1)将所有实体(即长方形)及其相对应的属性(指向实体的椭圆)以关系模式 R (A1,A2,~~~An)的形式依次列出;(与一对一相同)
(2)再将关系(菱形)及其对应实体的主码和菱形本身属性以关系模式R(A1,A2,~~~An)的形 式依次列出,其中关系对应R,主码对应A,此关系模式的主键必须指定n端的主码为关系模 式的主键
3.多对多的情况:
(1)将所有实体(即长方形)及其相对应的属性(指向实体的椭圆)以关系模式 R (A1,A2,~~~An)的形式依次列出;(与一对一相同)
(2)再将关系(菱形)及其对应实体的主码和菱形本身属性以关系模式R(A1,A2,~~~An)的形 式依次列出,其中关系对应R,主码对应A,此关系模式的主键必须由n端、m端...的主码共 同构成
例题:(真题)
解:
边栏推荐
- Fairygui bar subfamily (scroll bar, slider, progress bar)
- MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
- 阿里云微服务(三)Sentinel开源流控熔断降级组件
- [algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
- 阿里云微服务(四) Service Mesh综述以及实例Istio
- Dark chain lock (lca+ difference on tree)
- Edit distance (multi-source BFS)
- Experience summary of autumn recruitment of state-owned enterprises
- 【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现
- 错误:排序与角标越界
猜你喜欢
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
What are the advantages of using SQL in Excel VBA
10 minutes pour maîtriser complètement la rupture du cache, la pénétration du cache, l'avalanche du cache
Application architecture of large live broadcast platform
【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现
几道高频的JVM面试题
[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等
系统设计学习(三)Design Amazon‘s sales rank by category feature
How to ensure data consistency between MySQL and redis?
KF UD分解之UD分解基础篇【1】
随机推荐
阿里云微服务(三)Sentinel开源流控熔断降级组件
Implementation of Excel import and export functions
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
[rtklib 2.4.3 B34] version update introduction I
Problems and solutions of robust estimation in rtklib single point location spp
rtklib单点定位spp使用抗差估计遇到的问题及解决
面试必备:聊聊分布式锁的多种实现!
Several high-frequency JVM interview questions
Record: solution of 404 error of servlet accessing database in dynamic web project
Exception: ioexception:stream closed
The earth revolves around the sun
MySQL 30000 word essence summary + 100 interview questions, hanging the interviewer is more than enough (Collection Series
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和
闇の連鎖(LCA+树上差分)
NovAtel 板卡OEM617D配置步骤记录
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
Wechat applet development experience
Novatel board oem617d configuration step record
Fgui project packaging and Publishing & importing unity & the way to display the UI
What are the advantages of using SQL in Excel VBA