note5-relationalalgbra

# note5-relationalalgbra - CSc134 Organization...

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

1 CSc 134 Database Management and File  Organization 5. Relational Algebra Ying Jin Computer Science Department California state University, Sacramento

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

View Full Document
2 Relational Algebra A set of operations for the relational model.  Enable a user to specify basic retrieval  requests.  The  algebra operations  produce new  relations. The result of a retrieval is a new relation. A sequence of relational algebra operations  forms a  relational algebra expression result  a relation  represents the result of a database query.
3 Topics on relational algebra Unary Relational Operations  Select project Relational Algebra Operations From Set  Theory Union, intersection, minus Cartesian product Binary Relational Operations Join equijoin, natural join variations of join Division

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

View Full Document
4 The SELECT Operation σ   <selection condition>  (R) Filter - only those tuples that satisfy a  qualifying condition appear in the result. Result:  subset  of the tuples  Examples σ   DNO=4 (Employee) σ   (DNO=4 and salary>2500) or (DNO=5 AND salary>3000) (Employee)
5

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

View Full Document
6 The SELECT Operation  (Cont.) Commutative σ   <cond1>  ( σ   <cond2>  (R)) =  σ   <cond2>  ( σ   <cond1>  (R)) A cascaded SELECT operation  may be  applied in any order σ <condition1> ( σ < condition2>  ( σ <condition3>  (   R))  σ <condition2>  ( σ < condition3>  ( σ < condition1>  ( R))) Cascade of SELECT operations into a single  SELECT operation σ  <cond1>  ( σ   <cond2>  (… ( σ   <condn> (R))…) =
7 The Project Operation This operation selects certain  columns  from  the table and discards the other columns. Creates a vertical partitioning –  one with the needed columns (attributes)  containing results of the operation  other containing the discarded Columns. π <list>  ( R 29 Example    π LNAME, FNAME,SALARY (EMPLOYEE)

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

View Full Document
8 The Project Operation (Cont.) π  removes any duplicate tuples The result of  π  is a set of tuples – a valid  relation π sex, salary (EMPLOYEE)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern