Re: abstraction of table relationships
Date: Fri, 08 Sep 2006 00:30:09 GMT
Message-ID: <lQ2Mg.20515$%_1.14038_at_trndny07>
> In fact, the better solution to this problem is making better
> use of natural join. Schema design can and should be
> done with natural join in mind. Specifically, if there is
> any kind of key relationship between two tables, then
> the keys should have the same names, and the table
> should not have other, non-relating attribute names in
> common. This is actually quite trivial to do. (It's not
> possible in *every* case but it is certainly possible in
> a strong majority.)
>
I disagree with the use of common names to establish linkage between keys.
Specifically, a reflexive relationship, where an FK relates to a PK in the
same table.
Example: An employees table with two columns, namely, employee_id and
supervisor_id.
Another problem is the parts explosion table, where two FKs both relate to
the same PK.
Example: a part_usage table with two columns: component_part_id,
assembly_part_id
> At that point, the books per author query becomes:
>
> Select * from Books natural join Authorship natural join
> Persons where PersonId = 'Steven King';
>
> Quite simple. And the editors query is:
>
> Select * from Books natural join Editorship natural join
> Persons where PersonId = 'George R. R. Martin';
>
> In fact, the above queries make quite clear what the inter-table
> roles and relationships are, whereas omitting those relationships
> leaves this question quite unclear.
>
Meanwhile, I'm moving fast to stay a few steps ahead of the Spanish Insquisition, after using terms like "entity table" and "relationship table". Received on Fri Sep 08 2006 - 02:30:09 CEST