Search code examples
database-designdata-structuresrelational-databaseentity-relationship

Data structure/model of score keeping app for games (avoiding many-to-many-to-many)


I'm exploring a simple score-keeping app for playing the card game Rummy just as an exercise. I'm building it for iOS, but that is kind of irrelevant as it uses a SQLite data store so the data structure is applicable in any environment. Let me setup a use-case:

To start keeping score, you first set up your players. I'd like it to be possible to persist players so you can track stats and such. So, you either create new players or select existing.

Then, as you play, you add rounds with scores for each player.

When finished the game, players, and scores are all saved so you can view a log of past games.

The issue I'm running into is that a player can play many games, which have many rounds. But, when viewing a game, it has many rounds, with each round having many players (to display their scores).

Building an ERD for this shows how out-of-hand my perception of this data structure will be.

Silly ERD

It seems like I'm spinning in circles. Are there any examples of structuring this data, or can anyone show me where I'm getting off track?


Solution

  • Facts

    • Game exists.

    • Game has GameRound.

    • Player exists.

    • Player plays GameRound.


    Constraints

    • It is possible that some Game has more than one GameRound.

    • It is possible that some Player plays more than one GameRound and that for some GameRound, more than one Player plays that GameRound.


    Logical

    enter image description here