algebra

algebra - R el a ti ona l Al gebr a ( Ch 6.1-6.5 ) Yi Chen...

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

View Full Document Right Arrow Icon
Relational Algebra (Ch 6.1-6.5 ) 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 Query Relational Databases We have discussed SQL, the industry-standard query  language, for relational databases. Now we will discuss two formal query languages 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.
Background image of page 2
CSE 412 3 Outline Six Fundamental Operators Union Difference cartesian_product Selection Projection Rename Additional Operators Intersection θ -join natural_join division
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 SIX FUNDAMENTAL OPERATORS Let r and s be relations with schemas R  and S,  respectively union:    s = { t | t   r   t   s }  difference: r - s = { t | t   r   t   s} cartesian_product:                                      r  ×  s = { t | t = t r  t s  where  t r    r   t s    s }  selection: σ   P (r) projection: π   A (r)
Background image of page 4
CSE 412 5 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 5

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

View Full DocumentRight Arrow Icon
CSE 412 6 UNION r s = { t | t t s } Compatibility Restriction: r and s must be compatible the relations r and s must be of  the same arity (number of  attributes)  the domains of the ith attribute  of r must be the same as the  ith attribute of s Philosophy:  You shouldn't union together  relations that don't belong  together.  EXAMPLE Query: List the student information  for either computer science  or electrical engineering  majors.  Answer: cse_majors   eee_majors Schema: { id, name, class }
Background image of page 6
CSE 412 7 UNION Example Query Result id name class 1111 Student1 FR 2222 Student2 SO 3333 Student3 JR 4444 Student4 SR 5555 Student5 GR 6666 Student6 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 8 DIFFERENCE r - s = { t | t r t s} Restriction:  r and s must be  compatible  EXAMPLE Query : List  the  student  information for computer science majors, who are not double majors in electrical engineering. Answer : cse_majors - eee_majors Schema : { id, name, class }
Background image of page 8
CSE 412 9 DIFFERENCE Example Query Result id name class 1111 Student1 FR 3333 Student3 JR 5555 Student5 GR
Background image of page 9

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

View Full DocumentRight Arrow Icon
CSE 412 10 CARTESIAN PRODUCT r × s = { t | t = t r t s where t r t s s } Let  n r  and  n s  denote  the number of tuples in r and s There are n r  * n s
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/11/2009 for the course CSE 412 taught by Professor Davulcu,h during the Fall '08 term at ASU.

Page1 / 36

algebra - R el a ti ona l Al gebr a ( Ch 6.1-6.5 ) Yi Chen...

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

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