1

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 2

2

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

1
  • 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
2

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/

2
  • Why answer twice? You can edit your questions and answers.
    – Vlad
    Commented Jun 16, 2018 at 19:40
  • I like the vector implementation, thank you! Commented Jun 17, 2018 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.