![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, Suppose there exists a relational database that supports a type system that includes union types. (For example, (int|string), "an int or a string" is a valid type.) Now suppose one had two tables, the first with one column named "a" of type int, the second with one column named "a" of type string. Table 1 has exactly one row, and that row has a=1. Table 2 has exacly one row, and that row has a="hello". What should be the result of a join/union of the two tables? (Join and union are the same in this example.) Specifically, what is the column type of the resulting relation? |
|
1. None; this causes a type error 2. (int|string) 3. Most specific supertype of int and string. (Possibly 'alpha'.) 4. alpha, the maximal supertype. |
#3
| |||
| |||
|
|
"Marshall Spight" <mspight (AT) dnai (DOT) com> wrote in message news yp4b.315439$Ho3.44679 (AT) sccrnsc03 (DOT) ..Nice question Marshall. |
|
So the key to your dilemma is to ask which choice best helps define/prevent execution errors. 1. None; this causes a type error 2. (int|string) 3. Most specific supertype of int and string. (Possibly 'alpha'.) 4. alpha, the maximal supertype. With 3 or 4, you effectively have an untyped relational algebra. You might not let function parameters get automatically cast up to the most specific supertype and therfore preserve some typing, but then you would have introduced a logical difference between functions and relations that I for one would prefer not to see. |
#4
| |||
| |||
|
|
Suppose there exists a relational database that supports a type system that includes union types. (For example, (int|string), "an int or a string" is a valid type.) Now suppose one had two tables, the first with one column named "a" of type int, the second with one column named "a" of type string. Table 1 has exactly one row, and that row has a=1. Table 2 has exacly one row, and that row has a="hello". What should be the result of a join/union of the two tables? (Join and union are the same in this example.) Specifically, what is the column type of the resulting relation? 1. None; this causes a type error 2. (int|string) 3. Most specific supertype of int and string. (Possibly 'alpha'.) 4. alpha, the maximal supertype. |
![]() |
| Thread Tools | |
| Display Modes | |
| |