Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mhopkins321's avatar

Need some help with the schema for "card game as a service"

Specifically, I'm working on a Cards Against Humanity "as a service" project. So in theory, I have the follow tables/models

  • teams
  • players
  • games
  • cards
  • some unknown model that is the pivot between players/games and cards

What I'm struggling with is how to maintain deck integrity. Meaning, there can be multiple concurrent games existing at the same time, each getting their own complete set of cards (a deck). Within each active game, it's important to make sure that the functionality is similar to a single, physical deck, where you can't have (for example) two King of Hearts show up.

The above logic leads to a schema similar to this Image of schema

My issue is that when you start write the code for the above, "decks" stops making sense. ie A player has many decks. wha?

Thoughts?

0 likes
4 replies
D9705996's avatar

From your schema i dont see the direct relationship between team and deck. A player plays in a team and a team plays a game. Would create a table for gamedeckcard. The pk is game id deck id and card id and has a played attribute. You can then update this table with the used and available cards

Also i hope its a cards against humanity like game and your not just copying the content as that is very ropey on a copyright front!

mhopkins321's avatar

@D9705996 would that table (gamedeckcard) have a model? Or would it just exist as a pivot table that laravel would traverse?

Please or to participate in this conversation.