Hey, I'm trying to setup a proper database structure for my basketball game data app and would like to incorporate relations to avoid duplicate data.
I'm on the free Appwrite Cloud plan, so I have one Database available.
My use case is this:
I have two different types of Collections: Player and League. A League has documents representing basketball game stats, one document per game per player. A Player has their overall points and so on, essentially only one document in this collection.
The Relation I want to introduce is in the form of linking a Player to their played games in the respective leagues.
Player can have many games Game can have 1 Player, so I selected the one-to-many relationship.
But, at least in the console, it's kinda confusing to select the attributes to use. I was trying to use leagueGames for the player collection and player for the league collection. This worked well for 1 player, but when i create the Relation in a collection for a second player, it cant create a relation attribute with the same key.
So this essentially defeats the purpose that I save data, because now I have to create ANOTHER attribute (e.g. leagueGames2) where I can select the second player.
What am I missing? I want to link different documents from a league collection to different players, is this currently possible?
Maybe I am approaching it from the wrong side, but when I try to create it from the league side, I have to choose only one collection to link.
When I read it again, it probably makes sense to introduce one collection for all players, as they consist of only one document each. Then this problem would solve itself...
so to sum it up:
collection players -> document for overall stats of each player
collection league -> document for each game and link an attribute 'player' to the corresponding player in the collection
Yes, this did the trick. Sorry for posting a trivial question but it helped me figure out my problem 🙂
Marking this as Solved
[SOLVED] 2Way Relationships Databases
Recommended threads
- Appwrite console is too heavy
The Appwrite console is too heavy And all of my services broken Any support , please
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- Increase by operators
I see appwrite have bunch of useful operators for querieng db. One more I would like to suggest is operators like increase the count of a int columns by 1,2.. ...