Re: implied foreign keys

[prev] [thread] [next] [Date index for 2004/10/01]

From: Tony Bowden
Subject: Re: implied foreign keys
Date: 14:04 on 01 Oct 2004
On Fri, Oct 01, 2004 at 02:18:33PM +0100, josh_f_peterson@xxxxx.xxx wrote:
> CREATE TABLE well (
>   well_id integer NOT NULL,
>   barcode VARCHAR2(12) NOT NULL,
>   other columns here,
>   CONSTRAINT well_PK PRIMARY KEY (well_id)
> );
> CREATE TABLE sample (
>   sample_id integer NOT NULL,
>   barcode VARCHAR2(12) NOT NULL,
>   other columns here,
>   CONSTRAINT sample_PK PRIMARY KEY (sample_id)
> );
> I'd like to join them using the barcode column these share, and so I set up the classes for the two as if for a regular foreign key:
> 
> # In the well class
> __PACKAGE__->has_a( barcode => 'DB::sample');

That's not going to work. This is saying that the value in the 'barcode'
column of 'well' is the primary key of the 'sample' table.

Is the barcode column in 'sample' unique? If so should it not be the PK
of that table? If not, then the relationship couldn't possibly work like
that anyway...

Tony

implied foreign keys
josh_f_peterson 13:18 on 01 Oct 2004

Re: implied foreign keys
Tony Bowden 14:04 on 01 Oct 2004

Re: implied foreign keys
Josh Peterson 15:35 on 01 Oct 2004

Re: implied foreign keys
William McKee 17:09 on 01 Oct 2004

Re: implied foreign keys
Tony Bowden 18:34 on 01 Oct 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52