calculus

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

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

View Full Document Right Arrow Icon
Relational Calculus (Ch 6.6-6.7 ) Yi Chen Dept 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 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!
Background image of page 2
CSE 412 3 Outline Tuple Relational Calculus (TRC) Expressions Expressing Relational algebra Operators Safety Domain Relational Calculus (DRC)
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 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)
Background image of page 4
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
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 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.
Background image of page 6
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
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 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
Background image of page 8
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'}
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

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

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

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