第2章 关系模型

第2章 关系模型

考试范围: 2.1 -2.6

考试题型: 计算题

考试内容:

关系模型的基本概念

笛卡尔积

关系

关系模式

关系实例

属性

元组

关系数据库模式

关系数据库实例

Superkey

Candidate Key

Primary Key

  • 关系模型的基本概念
    • The relational data model is based on a collection of tables. The user of the database system may query these tables, insert new tuples, delete tuples,and update (modify) tuples. There are several languages for expressing these operations.
    • 关系数据模型基于一组表。数据库系统的用户可以查询这些表,插入新的元组,删除元组,以及更新(修改)元组。有几种语言可以表达这些操作。
  • 笛卡尔积
    • 两个集合相乘的结果
  • 关系
    • the term relation is used to refer to a table
    • 术语“关系”用来指一个表
  • 关系模式
    • The schema of a relation refers to its logical design.The schema of a relation includes its attributes, and optionally the types of the attributes and constraints on the relation such as primary and foreign key constraints.
    • 关系模式指的是它的逻辑设计,关系模式包括其属性,以及可选的属性类型和对关系的约束,例如主键和外键约束。
  • 关系实例
    • an instance of the relation refers to its contents at a point in time
    • 关系的实例指的是它在某个时间点的内容
  • 属性
    • attribute refers to a column of a table
    • 属性指的是表中的一列
  • 元组
    • tuple is simply a sequence (or list) of values
    • 元组只是一个值序列(或列表)
  • 关系数据库模式
    • the logical design of the database
    • 数据库的逻辑设计
  • 关系数据库实例
    • a snapshot of the data in the database at a given instant in time.
    • 给定时刻数据库中数据的快照
  • Superkey:
    • A superkey of a relation is a set of one or more attributes whose values are guaranteed to identify tuples in the relation uniquely.

    • 关系的超键是一个或多个属性的集合,这些属性的值保证唯一地标识关系中的元组

  • Candidate Key:
    • A candidate key is a minimal superkey, that is, a set of attributes that forms a superkey, but none of whose subsets is a superkey.

    • 候选键是最小超键,即构成超键的一组属性,但它们的子集都不是超键

    • 若W是候选码,则必须满足两个条件 ①W的闭包为全集U ②W没有冗余

    • 求候选码的步骤

      设有关系模式R,U= {A,B,C}为R的属性集, F为R上的函数依赖集

      • ①只在F右部出现的属性,不属于候选码

      • ②只在F左部出现的属性,一定存在于某候选码当中

      • ③两边都没有出现的属性,一定存在于候选码中

      • ④其他属性逐个与②③的属性结合,求属性闭包 ,直至X的闭包等于U。若等于U,则X为候选码

        例题: 关系模式R,U= {ABCDE}, F= {AB–>C, AB–>E, CDE–>AB}, 求候选码
        解:
        ①没有只在F右部出现的属性
        ②D为只在F左部出现的属性,所以D一定在候选码中
        ③没有两边都没有出现的属性
        ④还有属性ABCE待考虑,逐个结合,求闭包
        AD的闭包是AD,不等于U
        BD的闭包是BD,不等于U
        CD的闭包是CD,不等于U
        ED的闭包是ED,不等于U (1个与之结合没找到候选码,继续两个与之结合)
        ABD的闭包是 ABCDE,等于U √
        ACD的闭包是ACD,不等于U
        AED的闭包是AED,不等于U
        BCD的闭包是BCD,不等于U
        BED的闭包是BED,不等于U
        CED的闭包是ABCDE,等于U √ (2个的结合找到了候选码,就不需要3个的结合了哦~)
        因此,候选码是ABD 和 CED。
        
  • Primary Key:
    • One of the candidate keys of a relation is chosen as its primary key.
    • 关系的候选键之一被选为其主键。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值