16.05.2016, 16:28
This is of how I thought of this:
- Main table factions with 2 columns: factionid (PRIMARY KEY and auto increment) and leader (default value 0).
- Child table factions_members with 2 columns: factionid (references to factions.factionid so if a faction is deleted from main table, all its members will be removed from this table as well) and userid (upon registering a unique ID for each player - references to players.userid).
For the query in /factions, you can use JOIN to get the player's name of the leader and COUNT for the total (rows) members of each faction.
- Main table factions with 2 columns: factionid (PRIMARY KEY and auto increment) and leader (default value 0).
- Child table factions_members with 2 columns: factionid (references to factions.factionid so if a faction is deleted from main table, all its members will be removed from this table as well) and userid (upon registering a unique ID for each player - references to players.userid).
For the query in /factions, you can use JOIN to get the player's name of the leader and COUNT for the total (rows) members of each faction.