数据库系统概念(第五版)AbrahamSilberschatz著,ch-公开课件(讲义).pptVIP

  • 14
  • 0
  • 约2.63万字
  • 约 84页
  • 2019-10-10 发布于广西
  • 举报

数据库系统概念(第五版)AbrahamSilberschatz著,ch-公开课件(讲义).ppt

Chapter 5: Other Relational Languages Chapter 5: Other Relational Languages Tuple Relational Calculus Domain Relational Calculus Query-by-Example (QBE) Datalog Tuple Relational Calculus A nonprocedural query language, where each query is of the form {t | P (t ) } It is the set of all tuples t such that predicate P is true for t t is a tuple variable, t [A ] denotes the value of tuple t on attribute A t ? r denotes that tuple t is in relation r P is a formula similar to that of the predicate calculus Predicate Calculus Formula 1. Set of attributes and constants 2. Set of comparison operators: (e.g., ?, ?, ?, ?, ?, ?) 3. Set of connectives: and (?), or (v)? not (?) 4. Implication (?): x ? y, if x if true, then y is true x ? y ???x v y 5. Set of quantifiers: ??t ??r (Q (t )) ??”there exists” a tuple in t in relation r such that predicate Q (t ) is true ?t ??r (Q (t )) ??Q is true “for all” tuples t in relation r Banking Example branch (branch_name, branch_city, assets ) customer (customer_name, customer_street, customer_city ) account (account_number, branch_name, balance ) loan (loan_number, branch_name, amount ) depositor (customer_name, account_number ) borrower (customer_name, loan_number ) Example Queries Find the loan_number, branch_name, and amount for loans of over $1200 Example Queries Find the names of all customers having a loan, an account, or both at the bank Example Queries Find the names of all customers having a loan at the Perryridge branch Example Queries Find the names of all customers having a loan from the Perryridge branch, and the cities in which they live Example Queries Find the names of all customers who have an account at all branches located in Brooklyn: Safety of Expressions It is possible to write tuple calculus expressions that generate infinite relations. For example, { t | ? t?? r } results in an infinite relation if the domain of any attribute of relation r is infinite To guard against the problem,

文档评论(0)

1亿VIP精品文档

相关文档