--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Maybe a dynamic model, or nested model, or something like?
--
Best Regards!
Li You
University of Science and Technology of China
It sounds like you have some db modelling confusion here.
Are you sure you don't just want a many-to-many between Game and User
with some data on an explicit through model "UserGameInfo" with some
per-user per-game data?
http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships
Now, maybe you mean that each game instance is a different /kind of
game/, and the per-game per-user data would be wildly different
for each game instance, but then you probably would use different
models for the different kinds of game.
ok, this is a way.
Let me describe this problem in more detail:
I have a Game model for each game. This model can be seen as a list of
all games, such as,
class Game(models.Model):
name = models.CharField(max_length = 128, unique = True)
available = models.BooleanField(default = True)
timestamp = models.DateTimeField(auto_now_add=True)
And usually a user just plays with a few of games, but there maybe
hundreds of games.
A user may have different level in different games, so I need to keep
record of the user's level in each game.
At the beginning, I want to create a table for each game. Only users
who play that game get their level logged in the game's table.
By using many-to-many field, I can record the level info of all games
in a single table. But I am a little afraid of the performance...
That is the origin of this question. Thank you all. :)
--
Best Regards!
"We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil. Yet we should not pass
up our opportunities in that critical 3%.A good programmer will not be
lulled into complacency by such reasoning, he will be wise to look
carefully at the critical code; but only after that code has been
identified" - Knuth
Your design actually described a through table for M2M, but you don't
want to do that because you fear that the performance will be bad.
Implement your design, and then work out whether performance will be
bad.
Even if it is, relational databases are designed to be used in this
manner. You could (depending upon the capabilities of your database)
partition the through table based upon the game type. With this
database configuration, you would have the effect of having one table
per game type, but without adding unnecessary complexity to your
software.
Cheers
Tom