Chapter08ARelationalAlgebra (1).pptx

Unary relational operations select select operation

Info icon This preview shows pages 9–16. Sign up to view the full content.

Unary Relational Operations: SELECT SELECT Operation Properties The SELECT operation <selection condition> (R) produces a relation S that has the same schema (same attributes) as R SELECT is commutative: <condition1> ( < condition2> (R)) = <condition2> ( < condition1> (R)) Because of commutativity property, a cascade (sequence) of SELECT operations may be applied in any order: <cond1> ( <cond2> ( <cond3> (R)) = <cond2> ( <cond3> ( <cond1> ( R))) A cascade of SELECT operations may be replaced by a single selection with a conjunction of all the conditions: <cond1> ( < cond2> ( <cond3> (R)) = <cond1> AND < cond2> AND < cond3> (R))) The number of tuples in the result of a SELECT is less than (or equal to) the number of tuples in the input relation R Relational Algebra and Calculus 9
Image of page 9

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

Query Results Refer to this Database State Relational Algebra and Calculus 10
Image of page 10
Unary Relational Operations: PROJECT PROJECT Operation is denoted by  (pi) This operation keeps certain columns (attributes) from a relation and discards the other columns. PROJECT creates a vertical partitioning The list of specified columns (attributes) is kept in each tuple The other attributes in each tuple are discarded Example: To list each employee’s first and last name and salary, the following is used: LNAME, FNAME,SALARY (EMPLOYEE) Relational Algebra and Calculus 11
Image of page 11

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

Unary Relational Operations: PROJECT The general form of the project operation is: <attribute list> (R) (pi) is the symbol used to represent the project operation <attribute list> is the desired list of attributes from relation R. The project operation removes any duplicate tuples This is because the result of the project operation must be a set of tuples Mathematical sets do not allow duplicate elements. Relational Algebra and Calculus 12
Image of page 12
Unary Relational Operations: PROJECT PROJECT Operation Properties The number of tuples in the result of projection <list> (R) is always less or equal to the number of tuples in R If the list of attributes includes a key of R, then the number of tuples in the result of PROJECT is equal to the number of tuples in R PROJECT is not commutative <list1> ( <list2> (R) ) = <list1> (R) as long as <list2> contains the attributes in <list1> Relational Algebra and Calculus 13
Image of page 13

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

Examples of Applying SELECT and PROJECT Operations Relational Algebra and Calculus 14
Image of page 14
Relational Algebra Expressions We may want to apply several relational algebra operations one after the other Either we can write the operations as a single relational algebra expression by nesting the operations, or We can apply one operation at a time and create intermediate result relations .
Image of page 15

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

Image of page 16
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '09
  • SUNANHAN

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern