For the site I’m working on, I want a user to have the ability to checkmark multiple boxes that represent things he/she might be interested, similar to StumbleUpon. A user would check ‘web development’ and ‘web design’ then click ‘Submit’, which would then store his preferences in a database.
Later, if somebody created a project that was tagged with one of the preferences he selected, that user would get an update. So if I made a new project that said “Building a Website” and checked the category “web development”, all users who had “web development” selected on their personal profiles would get some kind of message or email alerting them to the newly created topic.
What is the best way to implement this in MySQL format? I looked at some pages on managing hierarchical data (there will be generalized categories like “Computers” or “Music” and an admin will be able to add/delete/edit categories), but none of the methods seemed to be what I needed – at least, not in the way of thinking I’m stuck in. Perhaps there’s an easier answer out there that I’ve been overlooking?
Create a table containing the various interests. Say
Then a table which stores all the interests selected by a user as
And a project interest relation as
Now when a new project is added you can run a query similar to the following onw to get the users that the project is of interest
Or, using the explicit join syntax: