calculus

# calculus - R el a ti ona l Ca l cul us Ch 6.6-6.7 Yi Chen...

This preview shows pages 1–10. Sign up to view the full content.

Relational Calculus (Ch 6.6-6.7 ) Yi Chen Dept of Computer Science & Engineering Arizona State University

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

View Full Document
CSE 412 2 RELATI ONAL 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   SQL is declarative,       based on tuple relational calculus!
CSE 412 3 Outline Tuple Relational Calculus (TRC) Expressions Expressing Relational algebra Operators Safety Domain Relational Calculus (DRC)

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

View Full Document
CSE 412 4 TUPLE RELATI ONAL CALCULUS (TRC) {T | cond(T)} "The set of all tuples T that satisfy the condition cond". 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 atom s, specifying selection (and possibly, join conditions)
CSE 412 5 ATOMI C 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

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

View Full Document
CSE 412 6 ATOMI C 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, T be a tuple variable, 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 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.
CSE 412 7 VALI D TRC EXPRESSI ON 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

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

View Full Document
CSE 412 8 UNIVERSITY EXAMPLE Schema & Instance eee_majors id name class 2222 Student2 SO 4444 Student4 SR 6666 Student6 SR cse_profs name office Prof1 Office1 Prof2 Office2 cse_courses crsid crstitle CSE412 Database Management CSE513 Rules in Database Systems CSE514 Object Oriented Databases cse_majors id class 1111 Student1 FR Student2 SO 3333 Student3 JR Student4 SR 5555 Student5 GR teaches tname tcrsid Prof1 CSE412 Prof1 CSE513 Prof2 CSE514
CSE 412 9 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'}

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 34

calculus - R el a ti ona l Ca l cul us Ch 6.6-6.7 Yi Chen...

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

View Full Document
Ask a homework question - tutors are online