Oliver,

mind that JOINs do not work on GAE. Even if portability is not an
issue for you, it is for web2py. This means web2py does not upport
APIs that work on GAE but not otherwise.

You can mimic the GAE list property in a portable way using:

db.define_table("Player",
      SQLField("name", "string"))

db.define_table("Team",
      SQLField("name", "string"),
      SQLField("player_ids", "text"))

db.define_table("Match",
       SQLField("ground", "string"),
       SQLField("result", "string"),
       SQLField("team_ids", "text"))

db.Team.player_ids.requires=IS_IN_DB(db,'Player.id','%(name)
s',multiple=True)
db.Match.team_ids.requires=IS_IN_DB(db,'Team.id','%(name)
s',multiple=True)

The multiple=True makes the text field work like a list_of_integers in
a portable way and will render the field with a "select multiple".

You still have a problem because this is (as is list_of_interegers) is
closer to tagging than many to many. This means that even if a Match
refers to a Team, the Team does not refer to the Match. You can mimic
this as you suggested but you will run into trouble because the
different fields would not be linked by a Join. GAE does not support
JOINs and it will do so in the future.

Mind that this requires 1.55rc3 in

http://mdp.cti.depaul.edu/examples/static/155rc2/web2py_src.zip
http://mdp.cti.depaul.edu/examples/static/155rc2/web2py_win.zip
http://mdp.cti.depaul.edu/examples/static/155rc2/web2py_osx.zip

Massimo



On Jan 2, 7:28 am, "sudhakar m" <[email protected]> wrote:
> Hi Robin,
>
> Thanks for the explanation. But I still couldnt quite get it right. This is
> what I have.
>
> For example in case of cricket match,
>
>    1. Each match has many teams(say 2)
>    2. Each team has many players
>    3. Each Player belongs to many teams
>
> So we have many-to-many relationship between match & team, team & player
>
> If I can use ListProperty, I can define them as
>
> db.define_table("Match",
>       SQLField("Team_ids", "*list_of_integers*"),
>       SQLField("ground", "string"),
>       SQLField("result", "string"))
>
> db.define_table("Team",
>       SQLField("name", "string"),
>       SQLField("player_ids", "*list_of_integers*"),
>       SQLField("Match_ids", "*list_of_integers*"))
>
> db.define_table("Player",
>       SQLField("name", "string"),
>       SQLField("Team_ids", "*list_of_integers*"))
>
> db.Team.Match_ids.requires=IS_IN_DB(db, 'Match.id')
> db.Player.Team_ids.requires=IS_IN_DB(db, 'Team.id')
>
> If I have to do the same in relational db way, i have to,
>
>    1. create a join table Match_Team & define a HABTM between match & team
>    2. create a join table Player_Team with HABTM again.
>
> Although the second approach works perfectly in relational db, I am
> wondering is this the right way to represent the data in a Flat database
> like BigTable.
>
> Portability is not an issue for me. But I would like to make use of app
> engine to full extent.
>
> Sorry for my ignorance. I m learning all three(python, gae & web2py) at the
> same time ;)
> Sudhakar.M
> A mind once stretched by a new idea never regains its original dimension. -
> Oliver Wendell Holmes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to