第2章关系模型(relational.pptVIP

  • 1
  • 0
  • 约8.08千字
  • 约 59页
  • 2019-11-05 发布于湖北
  • 举报
第2章:关系模型(Relational Model) 关系模型 关系运算 关系完整性约束 Branch 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 Example: if customer-name = {Jones, Smith, Curry, Lindsay} customer-street = {Main, North, Park} customer-city = {Harrison, Rye, Pittsfield} Then r = { (Jones, Main, Harrison), (Smith, North, Rye), (Curry, North, Rye), (Lindsay, Park, Pittsfield)} is a relation over customer-name x customer-street x customer-city customer depositor 8.关系数据库 关系数据库就是若干关系构成的集合,一般来讲,数据库中数据的组织方式用模式图来表示: 3. 选择运算(Select Operation) F是条件表达式,由比较及逻辑运算符构成。 ? (and), ? (or), ? (not) =, ?, , ?. . ? Example of selection: ? branch-name=“Perryridge”(account) Select Operation – Example 4.投影(Project Operation) E.g. ?account-number, balance (account) 在投影的结果里,重复的元组将被删除(Duplicate rows removed from result, since relations are sets) Project Operation – Example Relation r: 5.改名运算(Rename Operation) 把一个关系的名称改成另外一个名称.一般来说用于对关系运算的结果进行命名。记为:?s(R) ?s(A1,??? ,An)(R): 把关系R的名字改为S,并且把S的属性依次命名为A1,??? ,An. ?s(customer) 8.自然连接(Natural-Join Operation) Natural Join Operation – Example Relations r, s: 9.除法运算(Division Operation)* Let r and s be relations on schemas R and S respectively where R = (A1, …, Am, B1, …, Bn) S = (B1, …, Bn) The result of r ? s is a relation on schema R – S = (A1, …, Am) r ? s = { t | t ? ? R-S(r) ? ? u ? s ( tu ? r ) } Division Operation – Example Another Division Example 10.复合运算(Composition of Operations) 由多个运算构成的复杂运算 Example: ?A=C(r ) Banking Example branch (branch-name, branch-city, assets) customer (customer-name, customer-street, customer-only) account (account-number, branch-name, balance) loan (loan-number, branch-name, amount) depositor (customer-name, account-number) borrower (customer-name, loan-number) Example Queries 贷款数额大于 $1200的贷款信息 Example Queries cont. 查找在银行中有借款,存款或二者均有

文档评论(0)

1亿VIP精品文档

相关文档