Appendix 1
1. Mathematical Relations
Assume we have two sets D1 and D2 where D1 = {2, 4} and D2 {1,3,5}
Cartesian Product:
D1 X D2 = {(2,1), (2,3), (2,5), (4, 1), (4,3), (4,5)}
Any subset of the Cartesian product is a relation. e.g.
R1 = {(2,1), (4,3)}
D1 D2
2,4 1,
35
2 1
4 3
Extend the notion of a relation to three sets
D1 = {1,3} D2 = {2,4} D3 = {5,6}
Cartesian Product
D1 X D2 X D3 = {(1,2,5),(1,2,6),(1,4,5),(1,4,6),(3,2,5),(3,2,6),(3,4,5),(3,4,6)}
Any subset of the Cartesian product is a relation. e.g.
R2 = {(1,2,6), (3,4,5)} D3
D2
D1 1, 2, 5,
3 4 6
1 2 6
3 4 5
Therefore given domains D1, D2, ..... Dn a relation is a set of n-tuples each of which has its
first element from D1, its second element from D2, its third element form D3, and it nth
element from Dn.
1
, n-tuple – a tuple with n values.
2. Database Relations
Applying the above concepts to databases, a relation schema can be defined as:
A named relation defined by a set of attribute and domain pairs.
Let A1, A2, A3, .... An be attributes with domains D1, D2, D3, .... Dn. Then the set:
{A1:D1, A2:D2, A3:D3, ..... An:Dn } is a relation schema.
Thus a relation R on this schema is a set of n-tuples. Each element in the n-tuple
consists of an attribute and a value of that attribute.
D1 D2 D3 Dn
d11, d12, d21, d22, d31, d32, ......... dn1, dn2,
d13, d23, etc. d33, dn3, etc.
.
etc. etc.
A1:d1 A2:d21 A3:d31 ......... An:dn1
A1:d12 A2:d22 A3:d32 ........ An:dn2
A1:d13 A2:d23 A3:d33 ....... An:dn3
2
1. Mathematical Relations
Assume we have two sets D1 and D2 where D1 = {2, 4} and D2 {1,3,5}
Cartesian Product:
D1 X D2 = {(2,1), (2,3), (2,5), (4, 1), (4,3), (4,5)}
Any subset of the Cartesian product is a relation. e.g.
R1 = {(2,1), (4,3)}
D1 D2
2,4 1,
35
2 1
4 3
Extend the notion of a relation to three sets
D1 = {1,3} D2 = {2,4} D3 = {5,6}
Cartesian Product
D1 X D2 X D3 = {(1,2,5),(1,2,6),(1,4,5),(1,4,6),(3,2,5),(3,2,6),(3,4,5),(3,4,6)}
Any subset of the Cartesian product is a relation. e.g.
R2 = {(1,2,6), (3,4,5)} D3
D2
D1 1, 2, 5,
3 4 6
1 2 6
3 4 5
Therefore given domains D1, D2, ..... Dn a relation is a set of n-tuples each of which has its
first element from D1, its second element from D2, its third element form D3, and it nth
element from Dn.
1
, n-tuple – a tuple with n values.
2. Database Relations
Applying the above concepts to databases, a relation schema can be defined as:
A named relation defined by a set of attribute and domain pairs.
Let A1, A2, A3, .... An be attributes with domains D1, D2, D3, .... Dn. Then the set:
{A1:D1, A2:D2, A3:D3, ..... An:Dn } is a relation schema.
Thus a relation R on this schema is a set of n-tuples. Each element in the n-tuple
consists of an attribute and a value of that attribute.
D1 D2 D3 Dn
d11, d12, d21, d22, d31, d32, ......... dn1, dn2,
d13, d23, etc. d33, dn3, etc.
.
etc. etc.
A1:d1 A2:d21 A3:d31 ......... An:dn1
A1:d12 A2:d22 A3:d32 ........ An:dn2
A1:d13 A2:d23 A3:d33 ....... An:dn3
2