• David Portas (12/6/2009)


    RBarryYoung (12/6/2009)How can a relational query "preserve keys" across relational operations like PROJECT and JOIN?

    Some examples:

    P = PROJECT(a,b) R

    If a is a key of R then a is a key of P

    If b is a key of R then b is a key of P

    Otherwise (a,b) is a key of P

    ...

    But this is a trivial example that dodges the concern that I raised. Specifically, what about:

    P = PROJECT(a,c,d) of R(a,b: c,d) ?

    Removing one of the columns of a multi-column candidate key leaves you with an ambiguous situation wherein it is impossible to "preserve keys" in any meaningful way. Sure you could declare the whole columnset (a,c,d) as a superkey, but that's not a relational key and ultimately meaningless since you can do that with ANY relation, relvar, relational rowset, or indeed with any SQL rowset so long as you use DISTINCT with your final SELECT. There's nothing actually being preserved here.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]