A tuple is a finite function which we formalise as a set of ordered pairs.
Since tuples are sets we inherit operations from set theory, such as equality (=), inequality (≠), subset (⊆), strict subset (⊂), superset (⊇), strict superset (⊃), union (∪), intersection (∩), difference (\) and membership (∈).
Let t be a tuple. Then for each (a,v) ∈ t, a is called an attribute and v is called the value of attribute a for tuple t.
dom(t) denotes the domain (the set of attributes) of tuple t. i.e. dom(t) = { a | (a,v) ∈ t }
We use dot notation to represent function application: t.a denotes the value of attribute a for tuple t.
Note that the set of ordered pairs is not ordered. The values are identified by name, not by ordinal position.
For example, the following set denotes a tuple:
{ (S#, S1), (SNAME, Smith), (STATUS, 20), (CITY, London) }
The attributes of this tuple are S#, SNAME, STATUS and CITY. The value of the attribute STATUS is 20 for this tuple.
The degree or arity of a tuple means its cardinality. An n-ary tuple means a tuple of degree n.
There is a single tuple of degree 0 called the empty tuple which is formalised as the empty set ∅.
Every subset of a tuple is a tuple.
This corresponds to the restriction of a set of ordered pairs onto a subset of the domain to give another set of ordered pairs (see function restriction []).
This is called projection of a tuple to give another tuple.
Given tuple t and a set of attributes p satisfying p ⊆ dom(t), let restrict(t,p) denote the tuple which is the subset
of t having domain p.
That is, restrict(t,p) = { (a,v) ∈ t | a ∈ p }
Given tuple t, a set of attributes p satisfying p ⊆ dom(t) and an attribute a ∉ dom(t), let wrap(t,p,a) denote the tuple where the attributes in p are moved out of t and into a tuple-valued-attribute named a added to t.
wrap(t,p,a) = restrict(t, dom(t)\p) ∪ { (a, restrict(t,p)) }
The reverse is the unwrap function:
unwrap(t,a) = restrict(t, dom(t)\{a}) ∪ t.a
This is the inverse is the sense that it is always the case that
unwrap(wrap(t,p,a),a) = t
Date and Darwen use the syntax (t WRAP { a1, ... , an } AS a)
for the wrap function
and (t UNWARP a)
for the unwrap function. See page 145 of
Introduction to Database Systems (eighth edition).
Some authors have used the tern domain to mean type, in a typed formalism of tuples and relations. For example on page 111 of Introduction to Database Systems (eighth edition) Chris Date writes:
First, types are also called domains, especially in relational contexts; in fact, we used this latter term ourselves in earlier editions of this book, but we now prefer types.
However mathematicians commonly use the term domain in the sense of the domain of a function. For example the domain of a tuple means the set of attributes.