Just to verify, this is enforced at the application level and is not a
true composite primary key at the database level, correct?


On Sep 30, 1:04 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> The easiest way is:
>
> db.table.produto_id.requires=IS_NOT_IN_DB(db
> (db.table.categoria_id==request.vars.categoria_id),'table.produto_id')
>
> Massimo
>
> On Sep 30, 11:38 am, Leandro - ProfessionalIT <lsever...@gmail.com>
> wrote:
>
> > Hi,
>
> >   I have a table with this fields:
>
> >    id
> >    categoria_cliente_id
> >    produto_id
> >    preco
>
> >   Well, I need to implement a constraint where the fields
> > categoria_cliente_id + produto_id are unique. for example:
>
> >    id - categoria_cliente_id - produto_id - preco
> >    01  01                            01              12.50   (OK)
> >    02  02                            01              10.00   (OK)
> >    02  01                            01              20.00   (this
> > violate the constraint, because duplicate the categoria_cliente_id and
> > produto_id)
>
> >   How to implement this constraint in my table definition in db.py ?
>
> >   I need create this constraint in my database or the DAL can generate
> > this to me ?
>
> > -- Leandro.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to