cs 157b spring 2008
Download
Skip this Video
Download Presentation
CS 157B Spring 2008

Loading in 2 Seconds...

play fullscreen
1 / 10

CS 157B Spring 2008 - PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on

CS 157B Spring 2008. Prof. Sin Min Lee Presented by Li Ch’i Ooi. Manipulating Information with the Relational Algebra [Ch. 6.1]. Relation is a set of tuples and that each tuple in a relation has the same number and types of attributes. Relational algebra includes : Selection Operators

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CS 157B Spring 2008' - peggy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cs 157b spring 2008

CS 157B Spring 2008

Prof. Sin Min Lee

Presented by Li Ch’iOoi

manipulating information with the relational algebra ch 6 1
Manipulating Information with the Relational Algebra [Ch. 6.1]
  • Relation is a set of tuples and that each tuple in a relation has the same number and types of attributes. Relational algebra includes :
    • Selection Operators
    • Projection Operators
    • Set Operators
    • Join and product Operations
selection operators
Selection Operators ()
  • Reduce the number of tuples in a set by selecting those that satisfy some criteria.
  • Example : lastName = ‘Doe’ (Customer) [ Select from Customer where lastName = ‘Doe’ ]

Customer

projection operators
Projection Operators ()
  • Reduce the size of each tuple in a set by eliminating specific attributes.
  • Example : lastName, firstNAme (Customer) [ project customer onto (lastName, firstName) ]

Customer

set operators
Set Operators (  -)
  • Manipulate two similar sets of tuples by combining or comparing.
  • Example : Rental  PreviousRental

Rental PreviousRental

set operators con t
Set Operators (  -) ...con’t
  • The union of two relations is a relation that contains the set of each tuple that is in at least one of the input relations.
  • Partial result of the Rental  PreviousRental
set operators con t1
Set Operators (  -) ...con’t
  • The intersection of two relations is the set of all tuples that occur in both input relations.
  • The intersection of the relations Rental  PreviousRental in the previous example will return an empty set.
  • Another example would be the intersection between the video IDs of the two tables.
  •  videoId (Rental)   videoId (PrevioutsRental) = Videotapes that are currently rented as well as those that have been rented before.
  • The set of all videotapes that have been rented previously but are not currently rented is expressed as follows:

 videoId (PreviousRental) -  videoId (Rental)

join and product operations
Join and Product Operations ()
  • Increase the size of each tuple by adding attributes
  • The Cartesian product produces a tuple of the new realtion for each combination of one tuple from the left operand and one tuple from the right operand. Example : Employee  TimeCard

Employee TimeCard

join and product operations con t
Join and Product Operations () ...con’t
  • The result of this operation has 30 tuples because there are 5 Employee and 6 TimeCard.
  • Partial result of Cartesian product Employee  TimeCard
join and product operations con t1
Join and Product Operations () ...con’t
  • A selection of those tuples where Employee.ssn equals TimeCard.ssn can be expressed by :

Employee.ssn = TimeCard.ssn (Employee  TimeCard)

  • This type of product is called a join. The join operation puts together related objects from two relations.
  • A Natural Join however is defined so that the shared attribute appears only once in the output table.
  • Ref. textbook Table 6.6 [natural join] vs Table 6.7 [join]
ad