Relational Algebra

The relational algebra is a mathematical concept of relation of the Set theory.

About the relational algebra

The relational algebra was invented in 1970 by Edgar Frank Codd, the research director of the center IBM of San Jose. It consists of a whole of formal operations on the relations. The relational operations make it possible to create a new relation (table) starting from elementary operations on other tables (for example union, the intersection, or the difference).

The principles of the relational algebra are used much nowadays by DBMS for the management of the data-processing databases like SQL, DBASE, etc

Elements of the relational model

Precise objects of the model

It is a question here of determining Fields (i.e., atomic type):
  • Numerical: entirety or reality (SQL: Int, Float, etc).
  • Character string (SQL: Tank (20), VarChar (32), etc).
  • Date (SQL: DATE, TIME, YEAR, etc).
  • Standard enumerated.

Relation or Table

A relation (within the meaning of the model of Codd) consists of two things:
  1. a Diagram: The format of the table. The diagram is fixed.
  2. an Extension: Contents of the table, which is a whole of tuples whose order does not have importance.

Example:

Diagram:

{Key: INT, Name: VarChar (20), Email: VarChar (20)}

Extension:

{ {Key: 1, Name: " Edgar" , Email: " edgar@xxxxx.xx"} {Key: 2, Name: " Frank" , Email: " Frank@xxxxx.xx"} … }

Requests in relational Algebra

To define an allowing whole of elementary operations, by possible combination, to obtain the anticipated results.

the selection (or restriction):

  • Notation: R: F \,

  • Given: A relation R \, and a formula F \, formed of a combination of comparisons and connectors logical.
  • Result: R: F = \ {R \ in R: R \, satisfies the condition given by F \} \,
  • Équivalent SQL: WHERE

projection :

  • Notation: R \,

  • Given: A relation R \, and together of attributes A \, of R \, .
  • Result: R \, , which is the Relation R \, where only the attributes of A \ are considered,
  • Équivalent SQL: SELECT

Operators ensemblists

The relational algebra has the usual operations on the units.

Are R (A) \, and S (B) \, two relations having for whole of respective attributes A \, and B \, :

  • Union : R \ cup S= \ {T: T \ in R \ or \ T \ in S \} \,

  • Intersection : R \ course S= \ {T: T \ in R \ and \ T \ in S \} \,
  • Difference : R-S= \ {T: T \ in R \ and \ T \ not \ in S \} \,
  • Produces Cartesian : R \ times S= \ {(R, S): R \ in R \ and \ S \ in S \} \,
  • Joint : R \ star S= \ {(has, B, c): (has, b) \ in R \ and \ (B, c) \ in S \} \,
  • Division : it takes in entry two relations R (x_1,…, x_m, y_1,…, y_p) \, and S (y_1,…, y_p) \, .

Thus, any tuple r \ in R \, breaks up into two tuples r= (T, S) \, ,

with t= (t_1,…, t_m) \, of diagram X= \ {x_1,…, x_m \} \, and
s= (s_1,…, s_p) \, of diagram y= \ {y_1,…, y_p \} \, .

and turns over the table of diagram X \, such as R/S= \ {T: \ forall S \ in S, \ (T, S) \ in R \} \,

division amounts giving “all X such as for all there…”

Examples

  • Relations of the base example:

Count Touristes: idTourist NomT Sport City ---------- ------- --------- --------- 1 Marc Paris Ski 2 Jean Toulouse Tennis 3 Frank Marseilles Football 4 Thomas Lyon Veils 5 max Paris Golf

Count Sports: Sport --------- Ski Cycling Tennis Football Veil Golf

Count Destinations: idTourist VilleD ---------- -------- 1 Cannes 2 Ibiza 4 Tokyo

  • Selection:

> Tourists: (City = " Paris") idTourist NomT Sport City ---------- ------- --------- --------- 1 Marc Paris Ski 5 max Paris Golf
  • Projection:

> Tourists City NomT City ------- --------- Marc Paris Jean Toulouse Frank Marseilles Thomas Lyon Max Paris
  • Joint:

> Touristes \ star \, Destinations idTourist NomT City VilleD Sport ---------- ------- --------- --------- -------- 1 Marc Paris Ski Cannes 2 Jean Toulouse Ibiza Tennis 4 Thomas Lyon Veils Tokyo

See too

Random links:Nizam Al-Mulk | Effect of reality | Ferdinand Poise | Lamar University | The Spy by love