Hello there,
I’m creating an application that will allow certain businesses (aka “venues”) to host tournaments for a specific sport.
Here are my schemas (simplified):
Venue
name: string
Team
name: string
players: [type: objectId, ref: User]
venue: [type: objectId, ref: Venue]
total_score: number
User
name: string
email: string
venue: [type: objectId, ref: Venue]
League
name: string
event_type: string
game: string
venue: [type: objectId, ref: Venue]
teams: [type: objectId, ref: Team]
players: [type: objectId, ref: User, default undefined]
The idea is that a venue can host multiple leagues. The leagues can be either “team” or “solo” type, and they will have many players. Players can be on different teams but not in the same league. Teams can also join different leagues. Both teams and players can visit different venues, but venues shouldn’t be able to see anything from other venues - as it would get overwhelming for them.
While designing this and implementing it in my app, I didn’t really account for teams participating in different leagues. It works, but as soon as you add or remove a player, it adds/removes them from every league that the team is a part of.
I also haven’t even gotten around to implementing a “solo” mode yet, but I thought just adding players to the player array in League would be enough.
One idea I had was to implement the Team like so:
Team
name: string
leagues: [
id: objectId, ref League
players: [type: objectId, ref User]
score: number
]
total_score: number
venue: [type: objectId, ref: Venue]
What do you think about my design? How would you approach this?
Thanks so much for looking.