Manipulating the Content of a Relational Database
The Data Manipulation Language (DML) for a relational
database inserts/removes/modifies content rather than structure (which is the responsibility of the DDL). This is what most people refer to when talking about a query language SQL was not designed from scratch, but was rather composed out of preceeding (and more formal) languages:
Relational Algebra Tuple Relational Calculus
Relational Algebra
The relational algebra is truly an algebra, with the same
sorts of structure, axioms, etc. as the algebra you learned in public school. It’s commonly used internally by query engines due to those axioms, etc. and the facility that they provide for rewriting a query in to alternative (potentially more efficient) forms.
Query Processing Schematic
Core Relational Algebra Operators
Select - s()()
Output only involves tuples for which the selection predicate evaluates as true
Project - p()()
Output only involves attributes listed by the operator
Core Relational Algebra Operators
Union -
Output involves all tuples appearing in either operand
Difference - –
Out involves only those tuples appearing the the first operand but not the second
Cross Product - X
Output involves the combining of each tuple in the first operand with each tuple in the second
Derived Operators
Join -
Form a cross product, then those tuples that match on common attributes
Intersection -
Output involves only those tuples appearing in both operands Equivalent to – ( – )
Division - /
Output is a set of tuple fragments such that each fragment derives from a set of tuples in the first operand such that they completely overlap the second operand