relcalc - CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 8....

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 8. RELATIONAL CALCULUS Department of Computer Science & Engineering Arizona State University
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 412/598 Relational Calculus 2 RELATIONAL CALCULUS Relational algebra is a procedural language, giving the operations to retrieve the data from the database. Relational calculus is a declarative (nonprocedural) query language, indicating the properties of the data to retrieve from the database. Tuple Relational Calculus (TRC) - variables represent tuples Domain Relational Calculus (DRC) - variables represent domains
Background image of page 2
CSE 412/598 Relational Calculus 3 TUPLE RELATIONAL CALCULUS (TRC) {T | cond(T)} "The set of all tuples T that satisfy the condition". Formal specification {T 1 .a 1 , T 2 .a 2 , . .., T n .a n | cond(T 1 , . .., T n , T n+1 , . .., T n+m )} where T i - tuple variables a i - attributes T i .a j - indicates attributes to be projected cond - is a formula constructed out of atoms, specifying selection (and possibly, join conditions)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 412/598 Relational Calculus 4 ATOMIC FORMULA ATOM r(T) where T is a tuple variable and r is a relation T i .a θ T j .b where θ {<, , =, , >, } T i .a θ c where c is a constant
Background image of page 4
CSE 412/598 Relational Calculus 5 ATOMIC FORMULA FORMULA A formula is composed of atoms using the following rules: 1. An atom is a formula. Its truth value is given by the truth value of the atom. 2. Let F, F 1 and F 2 be formulas, then the following are formulas: Formula Truth Value (F) TRUE when F is TRUE . not (F) T RUE when F is FALSE . F 1 and F 2 T RUE when F 1 and F 2 are TRUE . F 1 or F 2 is a formula T RUE when F 1 or F 2 are TRUE . (exists T) F T RUE if there exists at least one value for T such that F is TRUE for T. (forall T) F T RUE when F is TRUE for all values for T.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 412/598 Relational Calculus 6 VALID TRC EXPRESSION free variable is not explicitly quantified global variable bound variable is declared through quantification and its scope is the quantified formula local variable A valid TRC expression { T1, T2, …, Tn | F(T1, T2, … Tn) } has only the tuple variables appearing to the left of the vertical bar (|) free in F. Any other variable appearing in F must be bound. Free vs. Bound Variables
Background image of page 6
CSE 412/598 Relational Calculus 7 TRC Fundamental Relational Algebra Operators r s: {T | r(T) or s(T)} e.g. {T | cse_majors(T) or eee_majors(T)} r - s: {T | r(T) and not(s(T))} e.g. {T | cse_majors(T) and not(eee_majors(T))} σ P (r): {T | r(T) and P} e.g. {T | cse_majors(T) and T.class='SR'}
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 412/598 Relational Calculus 8 TRC Fundamental Relational Algebra Operators π A (r): {T.a 1 , T.a 2 , . .., T.a n | r(T)} where A={a 1 , a 2 , . .., a n } and A attr(r) e.g. {T.id, T.name | cse_majors(T)}
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/12/2010 for the course CSE 41412 taught by Professor Hassan during the Fall '10 term at University of Arizona- Tucson.

Page1 / 26

relcalc - CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 8....

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online