Lecture Database system concepts (5/e): Chapter 5 - Silberschatz, Korth, Sudarshan 

In this chapter, we start by presenting the relational algebra, which forms the basis of the widely used SQL query language. We then cover the tuple relational calculus and the domain relational calculus, which are declarative query languages based on mathematical logic. | 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: (., , , , , , ) 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 Find the loan number for each loan of an amount greater than $1200 {t | s loan (t [loan_number ] = s [loan_number ] s [amount ] 1200)} Notice that a relation on schema [loan_number ] is implicitly defined by the query {t | t loan t [amount ] 1200} Example Queries Find the names of all customers having a loan, an account, or both at the bank {t | s borrower ( t [customer_name ] = s [customer_name ]) u depositor ( t [customer_name ] = u [customer_name] ) Find the names of all customers who have a loan and an account at the bank {t | s borrower ( t [customer_name ] = s [customer_name ]) u depositor ( t [customer_name ] = u [customer_name ]) Example Queries . | 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: (., , , , , , ) 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
11    61    1    30-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.