On 10/24/05 4:07 PM, "John Siracusa" <[EMAIL PROTECTED]> wrote:

> On 10/24/05, Sean Davis <[EMAIL PROTECTED]> wrote:
>> I am a new user (as of about 2 hours ago).  I have two tables that have a
>> one-to-one relationship with a third (so, of course, there is a one-to-many
>> from the third to the other two).  The code looks like below.  However, I
>> get the following error message on compile and I do have foreign keys
>> present in the g_alias and g_refseq tables.  I can't figure out what I am
>> doing incorrectly.  Any help?
> 
> First question: what version of RDBO are you using?  Second question:
> can you post the db schema including all key definitions?
>

RDBO Version: 0.77

Schema:

create table g_main (
    tax_id integer,
    gene_id integer primary key,
    symbol varchar,
    locustag varchar,
    chromosome varchar,
    map_location varchar,
    description varchar,
    gene_type varchar,
    symbol_from_nomenclature_auth varchar,
    full_name_from_nomenclature_auth varchar,
    nomenclature_status varchar,
    discontinued boolean default false,
    new_gene_id integer default NULL
) without OIDS;
comment on table g_main is 'Main Entrez Gene Table';

create table g_alias (
    g_alias_id serial primary key,
    gene_id integer references g_main(gene_id) on update cascade on delete
cascade deferrable,
    synonym varchar
);

create table g_refseq (
    gene_id integer references g_main(gene_id) on update cascade on delete
cascade deferrable,
    refseq varchar primary key,
    version integer,
    refseq_gi integer,
    status varchar
);

 
> For the error message, it looks like it couldn't auto-generate a name
> for the foreign key, which strikes me as a bug.  But I'll need the db
> schema to figure it out for sure.
> 
> In the meantime, regarding this:
> 
>> package AnnoDB::Model::Gene::Alias;
>> use base qw(AnnoDB::Model);
>> 
>> __PACKAGE__->meta->table('g_alias');
>> __PACKAGE__->meta->relationship
>>   (
>>    gene => {
>>         type => 'one to one',
>>         class => 'AnnoDB::Model::Gene::Main',
>>         column_map => {gene_id => 'gene_id'},
>>        },
>>   );
>> 
>> __PACKAGE__->meta->auto_initialize();
> 
> The "__PACKAGE__->meta->relationship" line should be
> "__PACKAGE__->meta->relationships" with an "s"! :)

Oops.  Thanks.

> That will actually create a corresponding "one to one" relationship
> behind the scenes (this behavior is documented, I believe), but more
> importantly, it's an accurate reflection of the underlying table.  The
> rule of thumb (which I keep meaning to document) is:

Yes.  That was what I understood.  Therefore, I tried the same thing without
the relationships defined and got the same error.

>   If the table has a foreign key, then define it with foreign_keys()
> 
> Otherwise, feel free to use a "one to one" or "many to one" relationship.

I assume that auto_initialize will do this automatically--all except the
many-to-many?

Thanks,
Sean



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to