I'm trying to move over from my own pseudo-ORM to using Propel (as my previous code was effectively Active Record) and and struggling to find the 'best' way to solve the problem of having classes which are composed of both changing and fixed properties.
It's for a game where I have regions on the map which can change owner throughout the game, so I need to store the game id (as multiple games can be going on at once) and the current owner on the regions table, but I also need to reference things like the name of the region, whether you can recruit there, the starting owner, etc.; all of these are fixed for that region and don't change within the game or between games.
For instance, the region 'Kent' might be initially owned by the English, but could be taken by the French, but it's always called 'Kent', you can always recruit there and it's always part of the larger country 'England'.
Options I can see are:
- Having a lookup .ini file or database table not controlled by Propel and just having the name etc. as fields on the main regions table
- Have a 'details' table and a 'details_id' as a field on the regions table
- Create a class for every region with the 'details' hard coded (though this seems difficult to maintain and error check to me)
- Something 'better' that I haven't though of
This must be a standard problem and I apologise for not getting the search terms right, but I've been struggling with it on and off for a while now and can't make something work intuitively!
As requested to clarify my database structure -
Region table
id | game_id | owner | turn_last_conquered | details_id | population
----|---------|-------|---------------------|------------|-----------
1 | 100 |England| 2 | 1 | 10
2 | 101 | France| 3 | 1 | 12
Region Details table
id | name | port | fortified | starting owner | starting population
----|------|------|-----------|----------------|--------------------
1 | Kent | 1 | 0 | England | 13
Both entries in the region table correspond to Kent in different games. If I had the properties as part of the Region object/table then if I wanted to change the name of something in every game, I'd have to update all the affected rows, whereas if it was in a separate table then I'd only have to update that one and the change would propagate. My own system populated the Region object with the required fields, with Propel I'm trying to find a way around having a 'RegionDetails' object, but maybe I shouldn't be.