Hi!
Check this thread:
http://groups.google.com/group/web2py/browse_thread/thread/caaf68de3fbc0baf/b9812b04ac70ba8b?lnk=gst&q=Multiple+constraint#b9812b04ac70ba8b

In summary, you want to create a computed combined field, and require
that it is unique. A bit odd, but that's what you need to be able to
have validators working at the DAL level. Otherwise, you can of course
add SQL-level combined indexes (but specific to the database
selected), which if not respected will generate an error instead of a
friendly validator message.
BR, Andre

On 7 fév, 08:43, Mark Hayes <m...@deployfx.com> wrote:
> I'm new to web2py and can't seem to find out how to create a composite
> key.  Specifically I'm trying to create the following tables:
>
> db.define_table('volunteer',
>     Field('first_name', 'string', length=30, notnull=True),
>     Field('last_name', 'string', length=30, notnull=True),
>     Field('birthday', 'date', required=True),
>     Field('email', 'string', length=30))
> db.define_table('opportunity',
>     Field('name', 'string', length=30, notnull=True))
> db.define_table('interest',
>     Field('volunteer', db.volunteer),
>     Field('opportunity', db.opportunity))
>
> In the 'interest' table I want to ensure that the combination of both
> volunteer + opportunity is unique.  What is the best way to go about
> doing this?  Any help would be greatly appreciated, thanks!

Reply via email to