Relational Query Languages
A query language is a language using which a user can request data from the database.
Query Languages can be procedural (the user instructs the system to perform a set of operations on the database) or non-procedural (the user specifies only what information is needed without specifying how to obtain that information).
We will discuss the following relational query languages:
Relational Algebra (procedural)
Tuple Relational Calculus (non-procedural)
Domain Relational Calculus (non-procedural)
Relational Operators
A relational operator takes as input one or more relations and outputs a new relation.
selection of tuples
selection of columns (projection)
Note that duplicate tuples will be eliminated automatically.
join (cartesian product)
union
set difference
The set difference (-) operation can be performed on two relations that have the same attributes. The result will contain tuples that are in the first relation but not those that are in the second relation.
More about null values
Two nulls are treated to be the same
The result of any arithmetic operation involving a null value is null
Comparisons with null values return the special truth value: unknown
Three-valued logic using the truth value unknown:
OR:
(unknown or true) = true,
(unknown or false) = unknown
(unknown or unknown) = unknown
AND:
(true and unknown) = unknown,
(false and unknown) = false,
(unknown and unknown) = unknown
NOT:
(not unknown) = unknown
The result of select predicate is treated as false if it evaluates to unknown
Last updated