Is there a method for storing one-to-many relationships within a table? Say I had a Player, and the player had multiple Tickets. How could I store multiple ticket primary keys within one player?
2 Answers
Even if you do not directly support one-to-many, you can set up multiple indexes to:
Create a separate player, ticket struct. These become tables. Place a player_id in the ticket and create a secondary index using player_id. You can search for the player's tickets by using both the player_id and the ticket id.
The following links can help. https://developers.eos.io/eosio-cpp/docs/multi-index-table-tutorial
-
Ahh of coarse, I've worked with graph databases for so long that I'm no longer used to the old way of look ups. I realised you could even use the scope to do some tricky "grouping" like actions on tables. Commented Jun 17, 2018 at 4:06
The link below will be really helpful. There are many concepts and relationships between them.
https://trybe.one/the-ultimate-end-to-end-eos-dapp-tutorial-part-2/