Hey all!
It's been a while! Hopefully some of those SQL and Database experts are still around here *cough Alex cough*. I barely know anything about Database design and web programming, so I'm looking for any kind of tips/advice I can get... even pointing me towards helpful tutorials/docs would be awesome.
Well, lets get down to business:
My goal is to build a Team Management plugin for a Wordpress website. Here is a list of the very basic capabilities the plugin must have:
- Each team must have a name.
- Each team must have a logo.
- Each team must have at least 1 administrator (the creator).
- Each team can have multiple administrators.
- Team administrators must be able to invite users to the team and remove users from the team.
- Each team member must have a role (captain, regular player, bench player, etc.).
- Teams must be able to create their own custom roles and assign them to team members.
- Team members must be able to have multiple roles.
Note: Just to be clear, "roles" are simply titles. There are no special permissions (like administrator permissions) that come with a role.
Next, I will go over my database tables and the relationship between them. I'm not very familiar with the SQL semantics, so I might be using terms incorrectly. Hopefully I get my intentions through:
Table Name Column Name ... ... ... Column Name Notes Team Table Team ID [Primary Key (PK)] Team Name [Unique] Logo URI Date Created Team Names cannot be duplicated. Team Member Table Team ID [Foreign Key (FK)] User ID Date Joined Permission Level Team ID + User ID must be unique! This is called a compound key? Team Role Table Team ID [FK] Role ID Role Title Role Description Team ID + Role ID must be unique! This is called a compound key? Team Member Role User ID [FK] Role ID User ID + Role ID must be unique! This is called a compound key? Team Invitation Table Team ID [FK] Invited User ID Invitation Creator User ID Date Created Status Team ID + Invited User ID must be unique! This is called a compound key?
So, what do the experts around here think? Are these tables designed correctly according to normalization rules and what not? Also, clarification on the terms used to described compound keys and perhaps how I would query the SQL database for information in PHP would be greatly appreciated.
Results 1 to 2 of 2
Thread: Database Table Design Help
- 18 Jun. 2013 10:40pm #1
Database Table Design Help
- 30 Jun. 2013 11:05am #2
In the Team Member Role table is the Role ID also an FK? It looks like an intermediary table for a n:n relationship and so they should both be FKs?
Otherwise it looks alright. I assume you're integrating with Wordpress's user system (and hence the user ids are also FKs?) Just make sure you're not housing any redundant data and your indexes are all set up and you should be sweet.