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
- Seed db
hello there... is this correct way to seed appwrite
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...