I'm planing on making a browser game just for fun and to improve my skills, but I have an issue regarding the Software Architecture of the game:

I will be using an ORM to communicate with my database. Let's just talk about a browser game like Ogame or Tribal Wars. What is a model an what not? Would I make a Model for each Unit Type and each Building Type? Or will I just save the information (for example: which level a certain building is at) in one table and a dataset would look like this:


  • building1: 10
  • building2: 5
  • unit1: 89
  • ...

Which is the approach I should use and how can I determine what feature is a model and which not?

Thank you!


I see three approaches in general:

1) Each type has an own model (Main Building, Mine, Barracks). When a structure is built or upgraded the instance is modified (in it's own table). This instance is linked to a village.

2) There is a model for structures. There is an instance for each type. When a structure is built or upgraded a many to many relation is created or updated (with the level as a pivot)

3) I have a property for each building type on my village model.

Notice how this implementation use different amounts of rows in the DB.

Even more interesting: How to handle the units? I guess it's not that efficient if I'd have an instance for each unit, when I'm having 10,000 units per village.

I hope you get what problem I mean

  • \$\begingroup\$ I think #2 is the way to go. \$\endgroup\$ – Jacek Pietal Oct 24 '16 at 18:19
  • \$\begingroup\$ I think general read on databases and OOP should help you with analysis for the game models. \$\endgroup\$ – Jacek Pietal Oct 24 '16 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.