Re: O'Reilly interview with Date

From: Kenneth Downs <knode.wants.this_at_see.sigblock>
Date: Wed, 10 Aug 2005 17:18:16 -0400
Message-Id: <ef7qs2-f8g.ln1_at_pluto.downsfam.net>


Paul wrote:

>> In my own system I never manually code a join, I just specify the two
>> tables and it builds it out of the foreign key definitions.

>
> What if there is more than one foreign key constraint involving the two
> tables?
>
> Paul.

personally i distinguish them with a prefix code, which is put onto the end of the column(s) names.

So let's say I was cross-referencing a table to itself. In Andromeda notation we'd have something like this:

column SOMECOLUMN { description: Nada; type_id: int; } table EXAMPLES {
  column SOMECOLUMN { primary_key: Y; }
}

and then x-ref table:

table EXAMPLES_XREF {
  foreign_key EXAMPLES;
  foreign_key EXMAPLES { suffix: _to; }
}

which is equivalent to the following DDL:

create table examples (
  SOMECOLUMN int PRIMARY KEY
)

create table examples_xref (
  SOMECOLUMN int REFERENCES examples(SOMECOLUMN),   SOMECOLUMN_TO int REFERENCES examples(SOMECOLUMN) )

My DDL may be rusty because i wrote a program to do it for me and I don't do DDL anymore.

-- 
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth_at_(Sec)ure(Dat)a(.com)
Received on Wed Aug 10 2005 - 23:18:16 CEST

Original text of this message