This preview shows pages 1–7. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Database System Concepts, 5th Ed . Silberschatz, Korth and Sudarshan See www.dbbook.com for conditions on reuse Chapter 5: Other Relational Languages Chapter 5: Other Relational Languages Silberschatz, Korth and Sudarshan 5.<number> Database System Concepts , 5 th Ed., Aug 2005 Chapter 5: Other Relational Languages Chapter 5: Other Relational Languages Tuple Relational Calculus Domain Relational Calculus QuerybyExample (QBE) Datalog Silberschatz, Korth and Sudarshan 5.<number> Database System Concepts , 5 th Ed., Aug 2005 Tuple Relational Calculus 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 Silberschatz, Korth and Sudarshan 5.<number> Database System Concepts , 5 th Ed., Aug 2005 Predicate Calculus Formula 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: 5 t r ( Q ( t )) there exists a tuple in t in relation r such that predicate Q ( t ) is true 2200 t r ( Q ( t )) Q is true for all tuples t in relation r Silberschatz, Korth and Sudarshan 5.<number> Database System Concepts , 5 th Ed., Aug 2005 Banking Example 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 ) Silberschatz, Korth and Sudarshan 5.<number> Database System Concepts , 5 th Ed., Aug 2005 Example Queries 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  5 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} Silberschatz, Korth and Sudarshan...
View Full
Document
 Spring '10
 benny

Click to edit the document details