You should be aware that this "tagging" style is ok, and works - but the way
it works may not be the right thing for your application.

If you have limited references (say ~20 or so per a "many")  then this is
simple, efficient, and you can probably manage your many-to-many this way.

What this does is stores a set of table references (integers, basically) as
text delimited by "|", so you would have a reference in this style which
looks (for example) like

"|1|27|153|225|"

and your code would need to parse it.

To have "many" to "many", you would just have cross references like this,
one of the tag-style  "many" definitions in each of two tables.

I like the traditional way to do this, and that is to define a table to hold
the many, and there are advantages depending on what you want to do.

For example:

db.define_table('location',
           Field('name'))
db.define_table('transportation',
          Field('name'))

# many-to-many table - holds what transportation is available where
db.define_table('available',
          Field('location', db.location),
          Field('transport', db.transportation))

Now you can define sets for operations like this:

transport_list = ((db.location.id == db.available.location)
                & (db.transportation.id == db.available.transport))
for row in transport_list.select():
    print row.location.name, row.transport.name


On Tue, Jul 28, 2009 at 2:42 PM, Fran <francisb...@googlemail.com> wrote:

>
> On Jul 28, 5:47 pm, __future__ <wrigh...@gmail.com> wrote:
> > I am already confused about how to implement the Django style many-to-
> > many relationship in web2py.
>
> The Many<>Many support native to Web2Py is the Tagging-style:
> http://www.vimeo.com/2720410
>
> F
> >
>

--~--~---------~--~----~------------~-------~--~----~
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