Relational Algebra – Degree, Cardinality, Domain, Union Compatibility and Operators

Relational Algebra is defined as the set of methods which are applied to retrieve the data based on the defined requirements.

Those set of methods are called as Operators of Relational Algebra.

These Operators are divided into two types:

  • Native Operators
  • Set Theoretic Operators

Before knowing in detail about these operators we need to understand the following four definitions.

Degree d(R):    Total no of attributes/columns present in a relation/table is called degree of the relation and is denoted by d(R).

Cardinality |R|: Total no if tuples present in a relation or Rows present in a table, is called cardinality of a relation and is denoted by |R|.

Domain: Total range of accepted values for an attribute of the relation is called the domain of the attribute.

Union Compatibility: Two relations R and S are set to be Union Compatible to each other if and only if:

  1. They have the same degree d(R).
  2. Domains of the respective attributes should also be same.

UnionCompatibility

Now coming back to Operators:

  1. Set Theoretic
    • Union (∪)
    • Intersection (∩)
    • Minus (–)
    • Cartesian Product (X)
  2. Native
    • Selection (σ)
    • Projection (π)
    • Rename (ρ)
    • Divide (÷)
    • Join

Note: In order to apply Union, Intersection and Minus operators among any two given relations, the prerequisite is those relations should always be Union Compatible with each other.

suppose there are two relations R and S then following properties hold true:

d(R∪S) = d(R) = d(S) and max(|R|,|S|) ≤ |R∪S| ≤ |R| + |S| 

d(R∩S) = d(R) = d(S)  and 0 ≤ |R∩S| ≤ min(|R|,|S|)

d(R-S) = d(R) = d(S) and 0 ≤ |R-S| ≤ (|R|) or 0 ≤ |S-R| ≤ (|S|)

Example:

 

R S
A B
1 x
2 y
3 z
C D
1 x
4 p
5 q
6 s
7 t

R∪S

A/C B/D
1 x
2 y
3 z
4 p
5 q
6 s
7 t

R∩S

A/C B/D
1 x

R-S

A/C B/D
2 y
3 z

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s