关系模型跟oracle对象关系数据库资料.pptVIP

  • 0
  • 0
  • 约7.32千字
  • 约 34页
  • 2019-06-14 发布于湖北
  • 举报

关系模型跟oracle对象关系数据库资料.ppt

关系模型跟oracle对象关系数据库资料

第三章 关系模型及oracle对象关系数据库 关系的定义 关系(relation):一个关系对应一张二维表 元组(tuple):表中的一行即为一个元组 属性(attribute):表中的一列为一个属性,给每个属性起一个名字即属性名(ID,NAME,PHONE,SALES-REP-ID) 主码(primary key):表中的某个属性组,它可以唯一确定元组。each row of data in a table is uniquely identified by a primary key. It must contain a value 外码(foreign key):you can logically relate information from multiple tables using foreign keys. 关系模型 关系模型由关系数据结构,关系操作和关系完整性约束三部分组成。 数据结构 ——关系(二维表),它由行和列组成。 关系操作—— 常见的关系操作包括:选择select,投影project,连接join,除divide,并union,交intersection,差difference等查询query操作和增加insert,删除delete,修改update操作两大部分。 完整性——关系的三类完整性约束 实体完整性 、参照完整性、用户定义的完整性 关系代数 The relational algebra(关系代数) is the basis of SQL. Basic Structure ——Cartesian product(笛卡儿积) Formally, given sets D1, D2, …. Dn a relation r is a subset of D1 x D2 x … x Dn , Thus a relation is a set of n-tuples (a1, a2, …, an) where each ai ? Di (1) Select Operation – Example Notation: ? p(r) p is called the selection predicate Defined as: ?p(r) = {t | t ? r and p(t)} Where p is a formula in propositional calculus consisting of terms connected by : ? (and), ? (or), ? (not) Each term is one of: attribute op attribute or constant where op is one of: =, ?, , ?. . ? Example of selection: ? branch-name=“Perryridge”(account) (2) Project Operation – Example Relation r: Notation: ?A1, A2, …, Ak (r) where A1, A2 are attribute names and r is a relation name. The result is defined as the relation of k columns obtained by erasing the columns that are not listed Duplicate rows removed from result, since relations are sets E.g. To eliminate the branch-name attribute of account ?account-number, balance (account) (3) Union Operation – Example Relations r, s: Notation: r ? s Defined as: r ? s = {t | t ? r or t ? s} For r ? s to be valid: 1. r, s must have the same arity (等目,同元,same number of attributes) 2. The attribute domains must be compatible (e.g., 2nd column of r deals with the same type of values as does the 2nd

文档评论(0)

1亿VIP精品文档

相关文档