Re: [CDBI] Fwd: find_or_create() barfs with constraints

[prev] [thread] [next] [Date index for 2005/08/03]

From: Johnny Morano
Subject: Re: [CDBI] Fwd: find_or_create() barfs with constraints
Date: 10:14 on 03 Aug 2005
Isn't the primary key supposed always to be unique?

quote: 'The primary key of a relational table uniquely identifies each
record in the
table.' (http://databases.about.com/cs/administration/g/primarykey.htm)

So if you're using multiple columns for PK, the combination of those
columns (values) must unique.

Correct me if I'm wrong of course ;-)

cya

On Tue, 2005-08-02 at 15:53 -0700, Aaron Turner wrote:
> Ok, but what if the unique key is not the primary key?
> 
> --  
> Aaron Turner, Sr. Security Engineer                        
> <aturner@xxxxxxxxxx.xxx>
> 
> 
> On Aug 2, 2005, at 12:17 PM, Rhesa Rozendaal wrote:
> 
> > Aaron Turner wrote:
> >
> >> I'm looking to insert a record in table if it doesn't already  
> >> exist.   I've also created a unique key (across two columns) to  
> >> prevent other  access not via Class::DBI from causing problems.
> >>
> >
> > [snip]
> >
> >
> >> __PACKAGE__->table('mucore.variant_type');
> >> __PACKAGE__->sequence('mucore.variant_type_variant_typeid_seq');
> >> __PACKAGE__->columns(All => qw/variant_typeID suite_typeID   
> >> next_mutationID name description/);
> >>
> >
> > You should inform Class::DBI about the multi-column primary key:
> >
> >   __PACKAGE__->columns(Primary => qw/variant_typeID suite_typeID/);
> >
> > then add the other columns:
> >
> >   __PACKAGE__->columns(Essential => qw/next_mutationID name
> >                                        description/);
> >
> >
> >> # Note that there is a unique key over suite_typeID/name
> >>
> >
> > If you only supply the All column group, Class::DBI assumes the  
> > first column is your primary key. In most cases that is sufficient,  
> > but in this case you need to be explicit.
> >
> > Hope that helps,
> > Rhesa
> >
> >
> 
> 
> _______________________________________________
> ClassDBI mailing list
> ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
> 
        -- 
        
Johnny Morano | insaniac@xxxxxxxx.xxx | +32.473 894685
[ perl rookie ] | [ linux geek ] | [ web kid ] | [ all ]
'%*;s{}{ohn};s.$.n.;;%@;s|(.*?)$|$1y|;s%^%j%;%;;print;*%'


_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

(message missing)

Re: [CDBI] Fwd: find_or_create() barfs with constraints
Johnny Morano 10:14 on 03 Aug 2005

Generated at 09:40 on 09 Aug 2005 by mariachi v0.52