Associative Table

30 views
Skip to first unread message

Tom Nurkkala

unread,
Feb 15, 2012, 7:16:59 PM2/15/12
to web2py-users
When creating a simple associative table between two (or more) other
tables, is there a way to tell web2py not to create the ID field?

thanks,
tom.

pbreit

unread,
Feb 15, 2012, 8:14:44 PM2/15/12
to web...@googlegroups.com
I don't believe so. Is there any reason you need to avoid that column? You should be able to disregard it fairly easily.

Anthony

unread,
Feb 15, 2012, 8:19:40 PM2/15/12
to web...@googlegroups.com

lyn2py

unread,
Feb 15, 2012, 11:14:09 PM2/15/12
to web2py-users
Agree with the Anthony. Not advisable.

On Feb 16, 9:19 am, Anthony <abasta...@gmail.com> wrote:
> Check
> outhttp://web2py.com/books/default/chapter/29/6#Legacy-databases-and-key...

Ross Peoples

unread,
Feb 16, 2012, 8:09:58 AM2/16/12
to web...@googlegroups.com
Good practice says you should ALWAYS have an identity (ID) field, even if you don't use it.

Cliff

unread,
Feb 16, 2012, 10:13:05 PM2/16/12
to web2py-users
If you want to avoid duplicate associations, check out
update_or_insert.

http://web2py.com/books/default/chapter/29/6#update_or_insert

In raw SQL you would use the two associated IDs as the primary key,
then use ON DUPLICATE KEY to trap the error.

Tom Nurkkala

unread,
Feb 18, 2012, 5:42:10 PM2/18/12
to web2py-users
On Feb 15, 8:14 pm, pbreit <pbreitenb...@gmail.com> wrote:
> I don't believe so. Is there any reason you need to avoid that column? You
> should be able to disregard it fairly easily.

Simply that it's not necessary to express a many-to-many relationship.
It's not a big deal. Thanks for the feedback!
Reply all
Reply to author
Forward
0 new messages