Unit 4
Unit 4
Output
:Examples of Select Operation:
• To select all instructors with salary greater than $90,000, the following statement is written:
Output
:Examples of Select Operation:
• To select instructors in Physics with salary greater than $90,000, the following statement is written:
Output
:Project Operation:
• The project operation is a unary operation that returns its argument relation,
with certain attributes left out.
• Projection is denoted by the uppercase Greek letter pi (Π).
• We list those attributes that we wish to appear in the result as a subscript to Π.
:Examples of Project Operation:
• To select specified attributes like ID, name and salary of the instructor relation, the following statement is
written:
Output
:Examples of Project Operation:
• To get the monthly salary of each instructor, the following statement is written:
Output
:Select Operation + Product Operation:
• Consider the more complicated query - “Find the names of all instructors in the Physics department.” We
write:
Πname (σdept name =“Physics” (instructor))
Output
:Cartesian Product Operation:
• The Cartesian product operation is denoted by a cross (×), allows us to combine information from any two
relations.
• Consider two relations named drinks and meals.
Πcourse id (σsemester =“Fall”∧ year=2017 (section)) - Πcourse id (σsemester =“Spring”∧ year=2018 (section))
:Assignment Operation:
• It is convenient at times to write a relational-algebra expression by assigning parts of it to temporary relation
variables.
• The assignment operation, denoted by ←. It is a convenient way to express complex queries.
σinstructor.ID=teaches.ID(instructor × teaches)
or
(instructor) ⋈instructor.ID=teaches.ID (teaches)
• Output of Inner Join:
σinstructor.ID=teaches.ID(instructor × teaches)
or
(instructor) ⋈instructor.ID=teaches.ID (teaches)
• Output of Left/Left Outer Join:
σinstructor.ID=teaches.ID(instructor × teaches)
or
(instructor) ⋈ instructor.ID=teaches.ID (teaches)
• Output of Right/Right Outer Join:
σinstructor.ID=teaches.ID(instructor × teaches)
or
(instructor) ⋈ instructor.ID=teaches.ID (teaches)
• Output of Full/Full Outer Join: