Formal Relational Query Languages
Formal Relational Query Languages
Formal Relational Query Languages
Query Languages
Outline
• Relational Algebra
• Tuple Relational Calculus
• Domain Relational Calculus
Relational Algebra
• Procedural language
• Six basic operators
• select:
• project:
• union:
• set difference: –
• Cartesian product: x
• rename:
• The operators take one or two relations as inputs
and produce a new relation as a result.
Select Operation
• Notation: (r)
p
• p is called the selection predicate
• Defined as:
• Example of selection:
dept_name=“Physics”(instructor)
Project Operation
• Notation: (r )
A1 , A2 ,, Ak
• Example: to find all courses taught in the Fall 2009 semester, but not in
the Spring 2010 semester
Find the set of all courses taught in the Fall 2009 semester, or in
the Spring 2010 semester, or both
Find the set of all courses taught in the Fall 2009 semester, but not in
the Spring 2010 semester
{ x , x , …, x | P (x , x , …, x )}
1 2 n 1 2 n