Your troops and your buildings could be handled in a similar fashion. In my game, I tackled troops by creating two tables in my database, one that contains all troops that can be raised, and one that contains all troops that have been raised.
Not all troops are accessible from every race in my game (for instance, race "A" may have a different set of troops than race "B"). When the player goes to the "Army" page, I load from the table of all troops the troops that are particular to that player's race (i.e. someone playing an Elf race (even though I don't use elves...) sees elf troops... someone playing an orc race see orc troops).
Then, when the player "raises" a troop, I either insert, or update (if that troop type is already there), the quantity in the "active" troops table.
Buildings could work in a very similar manner. I would make a table that contained all the buildings, the requirements for building, maintenance, benefits, disadvantages, etc, and another table of "completed" buildings which are assigned to a particular player ID. When a player completes construction of a building, add that building to the 'completed_buildings' table. If a player is only upgrading, then the entry for that building in the "completed" buildings table should already exist, and then you just update the record to reflect the new level.
If a player wanted to upgrade a building, you'd query the table of all buildings for the cost to upgrade (either a flat fee, or perhaps the cost gets incrementally higher for higher levels of buildings... either could be stored in the table). If they have the money, upgrade.. if not, error message.
Regarding how you start a new player with some buildings and not others, when the player registered (or perhaps confirmed their registration), you could run a script that initializes their setup.... so maybe to start with they get 100 gold, 1,000 light spearmen, and the buildings you mentioned. So under this setup I have explained, once they register, you'd run a query to set their gold to whatever number, you'd insert a record for 1,000 light spearmen into the "active" troops table, and you'd insert 3 records into the "active" buildings table (one for each building the player should start with).
This is really speaking in generic terms though, and there a millions ways to do what you're asking, but it really kind of depends on how you want to do it, and other functionality you have in your game. It sounds like you're rather early on in your game design, so I would highly recommend sitting down with a pencil and paper, writing down each "page" on your website you need, and then the functionality that you need to be able to do on each page. I think I could have saved myself about 3 years worth of development time if someone had mentioned that to me when I started...
