Chapter 20

Tuple / Relation Variables with Inheritance

Q: What type of inheritance do you hope for from your relations? A: Variable—it depends on how those relations change.

—Tinley Roquot(with apologies to Ambrose Bierce)

We saw in Chapter 15 that scalar values, at least, always have a unique most specific type, even with multiple inheritance. And the same goes for tuple and relation values as well, though once again the details are a little more complicated than they are in the scalar case. Such matters are the principal focus of this chapter.

IM PRESCRIPTION 27: TUPLE / RELATION MOST SPECIFIC TYPES

Let H be a heading defined as follows:

{ <A1,T1> , <A2,T2> , ... , <An,Tn> }

Then:

  1. If t is a tuple of type TUPLE H, meaning t shall take the form

    TUPLE { <A1,MST1,v1> , <A2,MST2,v2> , ... , <An,MSTn,vn> }

    where, for all j (j = 1, 2, ..., n), type MSTj is a subtype of type Tj and is the most specific type of value vj, then the most specific type of t shall be

    TUPLE { <A1,MST1> , <A2,MST2> , ... , <An,MSTn> }

  2. If r is a relation of type RELATION H, let the body of r consist of tuples t1, t2, ..., tm (m ≥0). Tuple ti (i = 1, 2, ..., m) shall take the form

    TUPLE { <A1,MSTi1,vi1> , <A2,MSTi2,vi2> , ... , <An,MSTin,vin> }

    where, for all j (j = 1, 2, ..., n), type MSTij is a subtype of type Tj and is the most specific type of value vij (note that MSTij is different for different tuples ti, in general). Then the most specific type of r shall be

    RELATION { <A1,MST1> , <A2,MST2> , ... , <An,MSTn> ...

Get Type Inheritance and Relational Theory 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.