Support of Relational Algebra Knowledge ... - Hornad - TUKE
Support of Relational Algebra Knowledge ... - Hornad - TUKE
Support of Relational Algebra Knowledge ... - Hornad - TUKE
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Syntax <strong>of</strong> select operation:<br />
σ ()<br />
σ - symbol <strong>of</strong> select operation<br />
condition - boolean expression specified over relation<br />
attributes<br />
relation_name – name <strong>of</strong> the relation which is processed<br />
by select operation.<br />
The result is a new relation that has the same attributes as<br />
original relation defined by relation_name.<br />
Projection<br />
Projection is vertical retrieve from relation and it selects<br />
table columns according to attribute list. Syntax <strong>of</strong> project<br />
operation:<br />
П ()<br />
П - symbol <strong>of</strong> project operation<br />
attribute_list – list <strong>of</strong> attribute (comma separated)<br />
displayed in the result<br />
relation_name – name <strong>of</strong> the relation which is processed<br />
by projection<br />
The result is a new relation with attributes that is specified<br />
in the attribute list in the same order as listed. If the<br />
attribute list contains only non-key attributes <strong>of</strong> the<br />
relation, then duplicate tuples will not be displayed in the<br />
final relation.<br />
Union<br />
Set operator UNION consolidates all tuples <strong>of</strong> two<br />
relations, eliminating duplicate records. Both relations<br />
must have the same relational scheme – degrees <strong>of</strong><br />
relations and domains <strong>of</strong> corresponding columns must be<br />
identical then the relations are union-compatible. Syntax<br />
R 3 = R 1 U R 2<br />
U - symbol <strong>of</strong> union operation<br />
Relations R 1 (a 1 , a 2 , … , a n ) and R 2 (b 1 , b 2 , … , b n ) must be<br />
union-compatible. The degree <strong>of</strong> both relations is n.<br />
The result is R 3 (c 1 , c 2 , … , c n ) relation with degree n and<br />
each tuple <strong>of</strong> R 3 is either from R 1 or R 2.<br />
If two relations are not union-compatible UNION<br />
operator cannot be used. To overcome this problem, it can<br />
be used the project operator, to narrow the number <strong>of</strong><br />
columns in each relation and the relations were unioncompatible.<br />
Intersect<br />
Intersection is a binary operation. The result tuples belong<br />
to both relations. Syntax<br />
R 3 = R 1 ∩ R 2<br />
∩ - symbol <strong>of</strong> intersect<br />
Relations R 1 (a 1 , a 2 , … , a n ) a R 2 (b 1 , b 2 , … , b n ) must be<br />
union-compatible. The degree <strong>of</strong> both relations is n. The<br />
result is R 3 (c 1 , c 2 , … , c n ) relation with degree n and each<br />
tuple from R 3 is in R 1 and also R 2 .<br />
Difference<br />
Difference operator returns all records from a single<br />
relation that are not in the second relation. Difference<br />
operator requires that both relations were unioncompatible.<br />
Syntax:<br />
R 3 = R 1 - R 2<br />
Relations R 1 (a 1 , a 2 , … , a n ) a R 2 (b 1 , b 2 , … , b m ) must be<br />
union-compatible. The degree <strong>of</strong> both relations is n. The<br />
result is R 3 (c 1 , c 2 , … , c n ) relation with degree n.<br />
Cartesian product<br />
Syntax<br />
R 3 = R 1 X R 2 , where<br />
R 1 (a 1 , a 2 , … , a n ) is a relation with degree n and the<br />
number <strong>of</strong> tuples (the cardinality <strong>of</strong> relation) is i.<br />
R 2 (b 1 , b 2 , … , b m ) is a relation with degree m and the<br />
cardinality <strong>of</strong> relation is j.<br />
The result R 3 (a 1 , a 2 , … , a n , b 1 , b 2 , … , b m ) is a relation<br />
with degree n + m and the cardinality <strong>of</strong> result relation is<br />
i*j.<br />
Cartesian product combines tuples from two relations.<br />
The result contains many tuples that have no relationship<br />
between them.<br />
Division<br />
Syntax<br />
R 3 = R 1 ÷ R 2<br />
R 1 (a 1 , a 2 , … , a n ) is a relation with degree n and the<br />
number <strong>of</strong> tuples (the cardinality <strong>of</strong> relation) is i.<br />
R 2 (b 1 , b 2 , … , b m ) is a relation with degree m and the<br />
cardinality <strong>of</strong> relation is j.<br />
R 3 (c 1 , c 2 , … , c k ) is a relation with degree k=n-m and the<br />
cardinality <strong>of</strong> relation is i ÷ j .<br />
The result relation contains tuples from R 1 that<br />
a combination with each tuple from R 2 is in R 1 . The result<br />
tuples has only attributes from R 1 .<br />
Join<br />
Join operation is one <strong>of</strong> the basic operations <strong>of</strong> relational<br />
algebra. It is a binary operation that combines two<br />
relations in the prescribed manner. It is one <strong>of</strong> the most<br />
important operations in relational databases, expressing<br />
the relationship between the two relations. Join R1 and R 2<br />
is a select operation applying over Cartesian product R 1<br />
X R 2 with particular condition. Join operation is defined<br />
over corresponding attributes both relations R 1 and R 2 .<br />
These attributes have the same domain and semantics.<br />
Syntax<br />
R 3 = R1 ⋈ R 2<br />
⋈ - symbol <strong>of</strong> join operation<br />
R 1 (a 1 , a 2 , … , a n ) and R 2 (b 1 , b 2 , … , b m ) - relations<br />
join_condition – boolean expression in the form<br />
AND AND … AND<br />
, where a condition has following form Ai Ө<br />
Bj. Ai is an attribute <strong>of</strong> R 1 and Bj is a attribute R 2 . Symbol<br />
Ө is one <strong>of</strong> next operators =, =, != .<br />
R 3 (a 1 , a 2 , … , a n , b 1 , b 2 , … , b m ) – a result relation with<br />
n+m attibutes<br />
The result relation contains corresponding tuples that<br />
satisfy a join condition.