WHAT’S A RELATION?

I’ll use our usual suppliers relation as a basis for examples in this section. Here’s a picture:

SNO | CHAR

SNAME | CHAR

STATUS | INTEGER

CITY | CHAR

S1

Smith

20

London

S2

Jones

10

Paris

S3

Blake

30

Paris

S4

Clark

20

London

S5

Adams

30

Athens

And here’s a definition:

Definition: Let {H} be a tuple heading and let t1, t2, ..., tm (m ≥ 0) be distinct tuples, all with heading {H}.[41] Then the combination, r say, of {H} and the set of tuples {t1, t2, ..., tm} is a relation value (or just a relation for short) over the attributes A1, A2, ..., An, where A1, A2, ..., An are all of the attributes in {H}. The heading of r is {H}; r has the same attributes (and hence the same attribute names and types) and the same degree as that heading does. The set of tuples {t1, t2, ..., tm} is the body of r. The value m is the cardinality of r.

I’ll leave it as an exercise for you to interpret the suppliers relation in terms of the foregoing definition. However, I will at least explain why we call such things relations. Basically, each tuple in a relation represents an n-ary relationship, in the ordinary natural language sense of that term, interrelating a set of n values (one such value for each tuple attribute); the full set of tuples in a given relation represents the full set of such relationships that happen to exist at some given time; and, mathematically speaking, that set of tuples is a relation. Thus, the explanation often heard, to the effect that the relational model is so called because it lets ...

Get SQL and Relational Theory, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.