【数据库系统原理】关系模型.ppt

上传人:marr****208 文档编号:149520748 上传时间:2020-10-27 格式:PPT 页数:119 大小:2.66MB
返回 下载 相关 举报
【数据库系统原理】关系模型.ppt_第1页
第1页 / 共119页
【数据库系统原理】关系模型.ppt_第2页
第2页 / 共119页
【数据库系统原理】关系模型.ppt_第3页
第3页 / 共119页
【数据库系统原理】关系模型.ppt_第4页
第4页 / 共119页
【数据库系统原理】关系模型.ppt_第5页
第5页 / 共119页
点击查看更多>>
资源描述

《【数据库系统原理】关系模型.ppt》由会员分享,可在线阅读,更多相关《【数据库系统原理】关系模型.ppt(119页珍藏版)》请在金锄头文库上搜索。

1、第三章:关系模型Chapter 3: Relational Model,关系数据库的结构Structure of Relational Databases 关系代数Relational Algebra 元组关系演算Tuple Relational Calculus 域关系演算Domain Relational Calculus 扩展关系代数操作Extended Relational-Algebra-Operations 数据库更新Modification of the Database 视图Views,关系示例Example of a Relation,基本结构Basic Structure,

2、给定一组域集,则关系是该域集的笛卡尔积的子集。即关系是N元集合,其中每个元素都隶属于某个域。Formally, given sets D1, D2, . Dn a relation r is a subset of D1 x D2 x x DnThus a relation is a set of n-tuples (a1, a2, , an) where ai Di 例:Example: if customer-name = Jones, Smith, Curry, Lindsaycustomer-street = Main, North, Parkcustomer-city = Harri

3、son, Rye, PittsfieldThen r = (Jones, Main, Harrison), (Smith, North, Rye), (Curry, North, Rye), (Lindsay, Park, Pittsfield) 其中,r是基于上述三个域的关系。is a relation over customer-name x customer-street x customer-city,属性类型Attribute Types,每个关系的属性都有一个名称。Each attribute of a relation has a name 各属性的取值范围集称为属性的域。The

4、 set of allowed values for each attribute is called the domain of the attribute 属性的值通常要求是原子性的,即不能分割。Attribute values are (normally) required to be atomic, that is, indivisible 例如,多值属性可以不是原子性的。E.g. multivalued attribute values are not atomic 例如,组合属性值不是原子性的。E.g. composite attribute values are not atom

5、ic 空值这一特殊的值包含在所有的域中。The special value null is a member of every domain 空值导致了许多操作定义的复杂性。The null value causes complications in the definition of many operations 在主体表示中可以先忽略空值,将其放在以后再考虑。 we shall ignore the effect of null values in our main presentation and consider their effect later,关系模式Relation Sch

6、ema,A1, A2, , An 是属性are attributes R = (A1, A2, , An )是关系模式 is a relation schema 例如,E.g. Customer-schema = (customer-name, customer-street, customer-city) r(R) 是关系模式R中的一个关系。is a relation on the relation schema R 例如,E.g.customer (Customer-schema),关系实例Relation Instance,关系的当前值(关系实例)用表来表示。The current va

7、lues (relation instance) of a relation are specified by a table r中元素t称为无组,由表中的行表示。的An element t of r is a tuple, represented by a row in a table,Jones Smith Curry Lindsay,customer-name,Main North North Park,customer-street,Harrison Rye Rye Pittsfield,customer-city,customer,属性attributes,元组tuples,关系是无

8、序的Relations are Unordered,元组的顺序不重要(元组可以以任意的顺序存储)Order of tuples is irrelevant (tuples may be stored in an arbitrary order) 例如,下面是无序的客户表。E.g. account relation with unordered tuples,数据库Database,数据库由多个关系组成。A database consists of multiple relations 企业信息被划分成若干部分,每一部分都存储着部分的信息。Information about an enterpr

9、ise is broken up into parts, with each relation storing one part of the information例如,E.g.: account :客户表存储帐户信息。 stores information about accounts depositor : 存储客户拥有的帐户的信息。stores information about which customer owns which account customer : 存储客户信息。stores information about customers 将所有信息存储在一个关系中会导致一

10、些问题:Storing all information as a single relation such as bank(account-number, balance, customer-name, .)results in 信息重复(如,两个客户拥有同一帐户时)repetition of information (e.g. two customers own an account) 需要空值(如,没有帐户的客户)the need for null values (e.g. represent a customer without an account) 范式理论(第七章)用于设计关系模式

11、。Normalization theory (Chapter 7) deals with how to design relational schemas,客户关系The customer Relation,储户关系The depositor Relation,银行系统的E-R图E-R Diagram for the Banking Enterprise,码Keys,Let K R 如果K是可以唯一R中元组的,则K是超级码,它应该可以对任何可能的关系都有这种唯一性。K is a superkey of R if values for K are sufficient to identify a

12、 unique tuple of each possible relation r(R) by “possible r” we mean a relation r that could exist in the enterprise we are modeling.例:Example: customer-name, customer-street and customer-name 上述都是客户表中的超级码(前提是没有同名的客户存在)are both superkeys of Customer, if no two customers can possibly have the same na

13、me. 如果K是最小的形式,则K是候选码。K is a candidate key if K is minimal例:Example: customer-name是客户表中的候选码,因为它既是超级码,同时又不可能找到比它更小的集合形式了。(引处,假定不允许同名客户存在) is a candidate key for Customer, since it is a superkey assuming no two customers can possibly have the same name), and no subset of it is a superkey.,在E-R集中确定码Dete

14、rmining Keys from E-R Sets,强实体集。实体集的主码即可作为关系的主码。Strong entity set. The primary key of the entity set becomes the primary key of the relation. 弱实体集。关系的主码由强实体集的主码和弱实体集的分辨符组合而成。Weak entity set. The primary key of the relation consists of the union of the primary key of the strong entity set and the dis

15、criminator of the weak entity set. 关系集。相关实体集的主码的并成为关系的超级码。Relationship set. The union of the primary keys of the related entity sets becomes a super key of the relation. 在二元多对一关系集中,多方实体集的主码成为关系的主码。For binary many-to-one relationship sets, the primary key of the “many” entity set becomes the relation

16、s primary key. 在一对一关系集中,关系的主码可以是任一实体集的主码。For one-to-one relationship sets, the relations primary key can be that of either entity set. 在多对多关系集中,关系的主码是主码的并。For many-to-many relationship sets, the union of the primary keys becomes the relations primary key,银行系统的模式图Schema Diagram for the Banking Enterprise,查询语言Query Languages,查询语言用于从数据库中提取信息。Language in which user requests information from the database. 语言的分类:Categories of languages 过程化的procedural

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号