I am working on a fun php game, as a hobby. I have already dusted it off 3 times now, so has been an ongoing process. However, this last instance I have deleted 90% of my database structure and have recreated most of it to make it as dynamic as possible and not hard coded.
As well, I have been in the process of rewriting my code to make it all object orientated, and cleaning it up.
I have 2 questions in regards to my database(using mysql 5.0)
(1) I am looking for a new way to implement my mapping scheme, trying to make it dynamic like the rest. Before I had a table for each "tile" that had fields for each of the directions in a hexagon shaped map tile system, then linked the tile_id in those directions. It also included an array of current player_id's that are located in that tile. Another array had the tiles object inventory. You get the idea, basically everything was hard coded.
Now I am trying to make it more flexible, my current thought is to have a few tables (map_cell, structures) Then have some many-many tables linking them all together. In this way one would have relationship between a tile_id and player_id. Another would have the tile_id and a structure_id. Obviously entering or exiting a structure would be easy to implement (unless it belonged to more then 1 map cell) However, trying to get the map links all dynamic seems to make it very complex.
Would it be best to just hard code this in, and give up the dynamic nature for the map? Also, would anyone advise me to not even use the database for the map, and just use map files located on the system, and create a class to handle the map itself, and just leave the players position and structures in the database?
(2) In trying to normalize my data, I have 1 table called types. This table only has the fields id, name, description. In this table I am inserting values to distinguish types for all other tables in the database. i.e. skill type/attribute type for the stats table to distinguish between them. Weapon/armor for the item table. Player/Item for the object_owner table(this is to distinguish where to look up the id in the owner field, to see who owns the item, another item or a player).
It seems it can be dangerous mixing the types of so many different tables into one, that don't relate with each other. I thought about using Enum fields in each of the tables requiring a type, however, this again would loose some of the dynamic nature of design. Am I making a mistake here, or any better solutions to this?
Thanks for taking the time to read this, and any feedback will be greatly appreciated.