I have to admit I read Markus too fast and I missed that point.

On Oct 8, 9:33 am, Yarko Tymciurak <yark...@gmail.com> wrote:
> On Thu, Oct 8, 2009 at 9:06 AM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > On a second thought.... why is this not supported?
>
> > Because I am not convinced this is a good idea.
>
> > If every record of table A only references one record of table B and
> > vice versa then perhaps there should be only one table AB.
>
> > If this is a one (A) to many (B) relation then A cannot contain a
> > reference to B because would not be unique.
>
> > If this is a many to many then there should be a link table. In your
> > case:
>
> > db.define_table('ports',
> >     Field('name','string')
> >     )
> >  db.define_table('agents',
> >    field('name','string')
> >     )
> >  db.define_table('port_agents',
> >     Field('port_id', db.ports),
> >     Field('agent_id',db.agents)
> >  )
>
> Using your own statement:
>
> I have port_agents, which are assigned to specific ports. One port
> might have several port_agents.
> At the same time each port might have a preferred agent,
>
> I think it is reasonable to assume that an agent may move between ports
> (even if only on rare occaision), so Massimo's example tables are - I think
> - good.  The only missing thing is somthing for your last statement,  and
> you will want to think about what makes more sense - is this an attribute of
> the port, or is this an attribute of the port_agents relationship.  I would
> probably go for the latter, and add an attribute for "preferred" pairing,
> but then you would have the possibility of many "preferred"s, so adding a
> Field('preferred_agent_id', db.agents)  to ports might be the way you will
> prefer (as it will limit you to a one-to-many relationship at worst).
>
> Yarko
>
> > It is also possible that I do not understand the problem you are
> > working on and I am completely wrong.
>
> > Massimo
--~--~---------~--~----~------------~-------~--~----~
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