[Dbix-class] Schema design query

Ovid publiustemp-dbic at yahoo.com
Fri Feb 27 16:30:20 GMT 2009


----- Original Message ----

> From: Dermot <paikkos at googlemail.com>

> > Yes, you are missing something. UNIQUE( x, y ) means that the
> > combination of X and Y must be unique. It's a mutli-column constraint.
> > So, you couldn't have two rows with cd_id=1, genre_id=2. But, your
> > example list would be just fine.
> 
> Thanx Rob I didn't realise that UNIQUE could bound over multiple
> columns like that.

In fact, assuming you're working with a properly normalized database, almost every table should be considered in practice (if not in reality) to have a unique constraint over all columns (aside from the ID) where the values are truly identifying.  (There's one counter-example I can think of, but in practice, I've never seen it).

 
Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6




More information about the DBIx-Class mailing list