Selection or Restriction
Opredicate(R) The selection operation works on a single relation R and defines a relation that contains only those tuples of R that satisfy the specified condition (predicate).
Example : List all staff with a salary greater than 10,000.
Osalary>10000(Staff)
The input relation is staff and the predicate is salary>10000. The selection operation defines a relation containing only those staff tuples with a salary greater than 10000. More complex predicates can be generated using the logical operators ^(And),v (OR ) and ~(NOT)
Projection
IIa1,....,an(R) The projection operation works on a single relation R and defines a relation that contains a vertical subset of R, extracting the values of specified attributes and eliminating duplicates.
Example : Produce a list of salaries for all staff, showing only the StaffNo,fName,lName, and salary details.
IIstaffNo,fName,lName,salary(Staff)
Unioin :
R U S The union of two relations R and S defines a relation that contains all the tuples of R, or S or both R and S, duplicate tuples being eliminated. R and S must be union-compatible.
Example :
List all cities where there is either a branch office or a property for rent.
IIcity(Branch) U IIcity(PropertyForRent)
Set difference
R-S The set difference operations defines a relation consisting of the tuples that are in relation R, but not in S. R and S must be union-compatible
IIcity(Branch) - IIcity(PropertyForRent) ( take only different )
Intersection
No comments:
Post a Comment