Next, the tuples of a relation are unordered, top to bottom. This property follows because,
again, a body is a set, and sets in mathematics have no ordering to their elements. (Thus,
for example, {a,b,c} and {c,a,b} are the same set in mathematics, and the same kind of thing
is naturally true in the relational model.) Of course, when we draw a relation as a table on
paper, we do have to show the rows in some top-to-bottom order, but that ordering
doesn’t correspond to anything relational. In the case of the suppliers relation of
Figure 1-3, for example, I could have shown the rows in any order—say, supplier S3, then
S1, then S5, then S4, then S2—and the picture would still represent the same relation.
NOTE
The fact that the tuples of a relation are unordered doesn’t mean queries
can’t include an ORDER BY specification, but it does mean that such
queries produce a result that’s not a relation. ORDER BY is useful for the
purpose of displaying results, but it isn’t a relational operator as such.
In similar fashion, the attributes of a relation are also unordered, left to right, because a
heading too is a mathematical set. Again, when we draw a relation as a table on paper,
we have to show the columns in some left-to-right order, but that ordering doesn’t
correspond to anything relational. In the case of the suppliers relation of Figure 1-3, for
example, I could have shown the columns in any left-to-right order—say STATUS,
SNAME, CITY, SNO—and the picture would still represent the same relation in the
relational model. Incidentally, SQL fails here too: SQL tables do have a left-to-right
ordering to their columns (another reason why SQL tables aren’t relations, in general).
For example, the pictures below represent the same relation, but two different SQL tables:
Partager