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
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...