Django Group Models

30 views
Skip to first unread message

yingi keme

unread,
Jul 26, 2017, 1:07:29 PM7/26/17
to Django users
What will be the best approach to designing a database schema that groups users in a collection of 4?

How will you create a model for lets say in an online game setting such that you want only 4 players in a single group based on thesame criteria amongst players?

Creating this model is problematic for me.

threes...@gmail.com

unread,
Jul 26, 2017, 2:58:59 PM7/26/17
to django...@googlegroups.com
Very roughly.

Something along the lines of this
  • I would create a Player (players) and a Match (matches) tables. 
  • The match table contains 4 keys (player1, player2, player3, player4) and some extra fields (created, status, etc.)
  • For each player you store some type of a skill (number) and a status (offline,lobby, playing, available), then alias, ping, etc.
  • The match-making logic could search for players within a certain skill range

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b0856edd-1adf-44b3-b1ac-bf20c39274ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Ledermann

unread,
Jul 27, 2017, 12:20:15 PM7/27/17
to django...@googlegroups.com
very roughly:

User (player) table
Game table

table that has foreign keys to player and match and a number field
that has a validator it is in [1,..,4]
unique together constraint in that table for player, match, number

that way you only have to change the validator when you have a match
with another amount of players
> https://groups.google.com/d/msgid/django-users/BED50B18-8CF7-44E7-866D-A67854921E13%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>
Reply all
Reply to author
Forward
0 new messages