Hello, I'm having a problem with my Travian-type browser game database design. I can't decide should I use subtype tables or not. I have the Unit class which contains all the variables required by units like infantry, ships, planes, ground vehicles, merchants, spies, etc.. Is this a good way to make the Unit table or should I use subtypes and create new table for every unit type? Every unit has it's own special attributes. For example: merchants don't have attack or defence, only ships can move at sea, ships can move only at sea, tanks can destroy buildings, planes can move both sea and ground and so on... So I thought maybe every Unit type needs it's own table like in the image below. I couldn't fully understand that subtype thing but this is what I came up with: I have never needed anything like this so I don't know which one is better. So which one should I use?
hmm...that's an interesting one, from the point of extensibility the subtypes are good as if you add a new unit type in the future that has an attribute that doesn't exist it won't affect the main table, it all stays self contained. I would look at this from an object oriented way and say that if you use subtypes and code classes for specific units you won't make a mistake