Re: Relational query with path expressions
Date: Fri, 3 Apr 2009 04:31:13 -0700 (PDT)
Message-ID: <13d9c422-4ce2-4d98-931c-e2626af83794_at_n7g2000prc.googlegroups.com>
On Apr 3, 5:34 pm, cim..._at_hotmail.com wrote:
> <<the user only has to specify the start and end attributes and the
> DBMS is able to deduce the joins that are required>>
> There is no such thing as a *start and end* attribute in a relation.
I meant that the user specifies a "start attribute", and an "end attribute" and supposing there is a Universal Relation there would be a projection on those two attributes which is a binary relation connecting them. This means it's possible to define a unary function that maps sets of the "start attribute" to sets of the "end attribute".
Of course, n-ary relations aren't generally decomposable to binary relations (in the sense of a JD) so this simplistic idea of composing unary functions cannot express many useful queries. In other words, path expressions that only try to navigate from attribute to attribute would be quite limiting.
That being said there are cases where the approach could be quite useful. For example, let x.f denote the application of unary function f to x, and let there be a many to many binary relation between parent and child, and we define corresponding parent and child unary functions.
We can use these functions to construct queries. For example, for any X we define:
X.grandparent = X.parent.parent
or just
grandparent = parent.parent
where the dot now denotes function composition rather than function application. The definition of the grandparent relation would conventionally require a self-join on the binary parent-child relation.
As another example, we could define a sibling function as follows
X.sibling = X.parent.child \ X
where we have used a set difference operator to ensure a person is never regarded as his or her own sibling.
The sibling function helps us define the cousin function:
X.cousin = X.parent.sibling.child
etc Received on Fri Apr 03 2009 - 13:31:13 CEST