| Relational Algebra |
Article Index for Relational |
Shopping Relational |
Website Links For Relational |
Information AboutRelational Algebra |
| CATEGORIES ABOUT RELATIONAL ALGEBRA | |
| data modeling | |
| relational algebra | |
| relational modeldata modeling | |
| relational algebra | |
| relational model | |
| mathematical relations | |
| data modeling | |
| SHOPPER'S DELIGHT | |
|
Relational algebra, an offshoot of First-order Logic , is a set of Relation s closed under Operator s. Operators operate on one or more relations to yield a relation. Relational algebra is a part of Computer Science . Relation Algebra in pure mathematics is an Algebraic Structure , relevant to Mathematical Logic and Set Theory . INTRODUCTION Relational algebras received little attention until the publication of E.F. Codd 's Relational Model Of Data in 1970. Codd proposed such an algebra as a basis for database query languages. The first query language to be based on Codd's algebra was ISBL , and this pioneering work has been acclaimed by many authorities as having shown the way to make Codd's idea into a useful language. Business System 12 was a short-lived industry-strength relational DBMS that followed the ISBL example. In 1998 Chris Date and Hugh Darwen proposed a language called Tutorial D intended for use in teaching relational database theory, and its query language also draws on ISBL's ideas. Rel is an implementation of Tutorial D. Even the query language of SQL is loosely based on a relational algebra, though the operands in SQL (tables) are not exactly relations and several useful theorems about the relational algebra do not hold in the SQL counterpart (arguably to the detriment of optimisers and/or users). Because a relation is interpreted as the Extension of some predicate, each operator of a relational algebra has a counterpart in predicate calculus. For example, the natural join is a counterpart of logical AND (). If relations ''R'' and ''S'' represent the extensions of predicates ''p1'' and ''p2'', respectively, then the natural join of ''R'' and ''S'' (''R'' ''S'') is a relation representing the extension of the predicate ''p1'' ''p2''. The exact set of operators may differ per definition and also depends on whether the unlabeled relational model (that uses mathematical relations) or the labeled relational model (that uses the labeled generalization of mathematical relations) is used. We will assume the labeled case here as this was the kind that Codd proposed and is thought by some to have been his most important innovation, as it eliminates dependence on an ordering to the attributes of a relation. Under this model we assume that Tuple s are partial Function s from attribute names to values. The attribute ''a'' of a tuple ''t'' is denoted in this article as ''t''(''a''). It is important to realise that Codd's algebra is not in fact complete with respect to First-order Logic . Had it been so, certain insurmountable computational difficulties would have arisen for any implementation of it. To overcome these difficulties, he restricted the operands to finite relations only and also proposed restricted support for negation (NOT) and disjunction (OR). Analogous restrictions are found in many other logic-based computer languages. Codd defined the term ''relational completeness'' to refer to a language that is complete with respect to first-order predicate calculus apart from the restrictions he proposed. In practice the restrictions have no adverse effect on the applicability of his relational algebra for database purposes. OPERATIONS As in any algebra, some operators are primitive and the others, being definable solely in terms of the primitive ones, are not primitive. It is useful if the choice of primitive operators parallels the usual choice of primitive logical operators. Although it is well known that the usual choice in logic of AND, OR and NOT is somewhat arbitrary, Codd made a similar arbitrary choice for his algebra. The six primitive operators of Codd's algebra are the '' Selection '', the '' Projection '', the '' Cartesian Product '' (also called the ''cross product'' or ''cross join''), the '' Set Union '', the '' Set Difference '', and the '' Rename ''. (Actually, Codd omitted the rename, but the compelling case for its inclusion was shown by the inventors of ISBL.) These six operators are fundamental in the sense that none of them can be omitted without losing expressive power. Many other operators have been defined in terms of these six. Among the most important are Set Intersection , division, and the natural join. In fact ISBL made a compelling case for replacing the Cartesian product by the natural join, of which the Cartesian product is a degenerate case. Altogether, the operators of relational algebra have identical expressive power to that of Domain Relational Calculus or Tuple Relational Calculus . However, for the reasons given in the Introduction above, relational algebra has strictly less expressive power than that of First-order Predicate Calculus without function symbols. Relational algebra actually corresponds to a subset of First-order Logic that is Horn Clause s ''without'' recursion and negation. Set operators Although three of the six basic operators are taken from and Set Difference , the two relations involved must be ''union-compatible'' — that is, the two relations must have the same Set Of Attributes . As Set Intersection can be defined in terms of Set Difference , the two relations involved in set intersection must also be union-compatible. The Cartesian product is defined differently from the one defined in Set theory in the sense that tuples are considered to be 'shallow' for the purposes of the operation. That is, unlike in set theory, where the Cartesian product of a ''n''-tuple by an ''m''-tuple is a set of 2-tuples, the Cartesian product in relational algebra has the 2-tuple "flattened" into an ''n''+''m''-tuple. More formally, ''R'' × ''S'' is defined as follows: | ||
|   | { Align | center cellpadding=20 |
|   | { Border | 1 |
|   | { Border | 1 |
|
|
|
|
|
| |