Is this the best way to setup your relationships if you want the  
ability to check if there is one there? I have a 'one to one'  
relationship, which i guess in my case is more a 'one to maybe one or  
maybe none' relationship. So if I do:

$foo->bar

Just to check if the relation exists, it gives a fatal error by  
default. If I do soft => 1 then i can stop it croaking. But this sort  
of tells Rose (and people looking at my code) that I haven't bothered  
to setup referential_integrity. Even though I have.

create table foo (
     id serial not null,
     foo text,
     primary key (id)
);

create table bar (
     foo_id int references foo(id),
     bar text,
     primary key (foo_id)
);

create table baz (
     foo_id int references foo(id),
     baz text,
     primary key (foo_id)
);

So if I load() foo object, there may be a bar object linking back to  
it, but there might not.

$foo = Foo->new(id => 1);
$foo->load;

if ($foo->bar) {
     print $foo->bar->bar;
}
if ($foo->baz) {
     print $foo->baz->baz;
}

As I said above, soft => 1 fixes it just fine. I'm just checking to  
make sure that's the best approach, or am I sort of lying to Rose by  
telling it these are 'one to one' relationships and i am not usinf  
ref integ.

regards,
Danial

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to