DBMS_3/

Relational Model

每一个table的构成:

rows and columns

every column has a column name

every tuple has a value for each column

The schema of a table is a structural description of tables.

𝑝𝑒𝑟𝑠𝑜𝑛_𝑠𝑐h𝑒𝑚𝑎 = (𝑛𝑎𝑚𝑒, 𝑠𝑡𝑟𝑒𝑒𝑡, 𝑐𝑖𝑡𝑦)

An instance is the actual content of a table at a certain time. It consists of all rows in the table.

𝑝𝑒𝑟𝑠𝑜𝑛(𝑝𝑒𝑟𝑠𝑜𝑛_𝑠𝑐h𝑒𝑚𝑎)

每一个instance即每一个person,它就是一行(有着person_schema的各项value),这些行没有关系是独立的,所以这个从上到下的顺序可以随便变化

super key

super key is a schema of attributes that can identify each tuple(多个,组合,辨别)

多个:很多属性都可以作为super key

组合:可以把多个属性组合在一起来辨别

 The candidate key is a minimal (not minimum) super key:

candidate就是最小的(不一定是只有一种value的,可能对于有些table它必须要靠两个value才能辨别)的super key。special super key.

The primary key is a candidate key that is the most appropriate to become the main key of the relation, never or rarely changed

special candidate key,也就是从primary key里面选一个呗,一个table只能由一个primary key。而且它的value不能有null的。

Foreign Keys

把不同的table连接其他的属性集

其中ISBN的关系中。books的ISBN是referenced relation,borrow的relation是referencing relation 

Only values occurring in the primary key attribute of the referenced relation may occur in the foreign key attribute of the referencing relation

It acts as a cross-reference between two tables as it references the primary key of another table

Logical Design

entity怎么画

1.Strong entity

 

2.Weak entity

要把连着的strong entity set的key写进来

 3.Composite attribute

 4.Multivalued Attributes

 把这个multivalued attribute和其他的attribute分开。如下图

5.ISA relationship

 下一级的schema要recall上一级的super key,也就是他们的key都相同

然后ISA有disjoint和overlapping的种类

对于disjoint且是totall

 这种情况就不需要写person了(因为人要不然就是学生要不然就是导师)

6.Muti-ary Relationship set

把相关的key都写进来

 7.aggregation

也是把所有的entity的key都写出来

relation怎么画

这里的问题就是是要新建schema还是用foreign key

但是这个relation_schema是根据关系的cardinal以及participantional而改变的

多对多,不管parti,写上两个entity的attribute

一对多,不管parti,写上many的attribute

一对一,随便写一个entity的attribute

但是一对一,至少有一个是total;或者是一对多,只要多的那一方是total,那么它不需要建立relation _schema,它的schema就是foreign key

记住一句话哈,一对多有多方total就不画。

 不画new schema就在该加的entity上加primary key作为foreign key,一般是total那边。

画new schema就以关系为名字,把两个primary key写在一起建立一个

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值