Reputation: 1557
I have a entity with around 70 attributes. It is about a battle in a game. Attacker have ships, while defender have ships and defense units. There are 10 different types of ships and 10 different types of defense units. There can be 0 or more ships and defense units of the same type. There are also 2 types of resources.
So I need to have attribute for every type of attacker ship before and after battle, every type of defender ship before and after battle, every type of defender defense unit before and after battle and every type of resource before and after battle (total 64 attributes) + attributes like id_battle (AUTO_INCREMENT), date...
Are there any problems with performance if table have 70 columns? Is there a better way to create this, maybe with more tables?
Upvotes: 0
Views: 48
Reputation: 94913
You would normalize your data. There will never be a column shiptype_a and another shiptype_b, but a table holding ship types and maybe others referencing its records in rows, not columns.
More or less:
"There are 10 different types of ships"
"and 10 different types of defense units."
"There can be 0 or more ships and defense units of the same type."
"There are also 2 types of resources."
"Attacker have ships, while defender have ships and defense Units [...] So I need to have attribute for every type of attacker ship before and after battle [...]"
That would lead to the following tables:
Or in the absence of ship and defense_unit_table:
If it is a board game with 64 fields like chess, then you can store the whole board, but you would usually still simply store the single fields rather than a record with 64 x n fields (fields1_is_what, field1_attacker_ship_id, field1_defender_ship_id, field1_defender_defense_unit_id, field2_ ...). This has little to do with performance, however, but more with the handling of the database and how to write queries.
Upvotes: 2