I was wondering if someone could point me to the right direction in setting up a flagging/notification system. I’d say very similar to a tagging system. If anyone knows of any tutorial or example setups, that would be great.
Purpose
Basically, the flags are to attach to data items including customers, properties, contractors, applications, etc with the role of notifying users of an important piece of info regarding that item. The flags should come from a predetermined list of items where users can add or remove.
Database
I was thinking about going with a 3 table setup.
- flags table: the list of available flags, along with settings determining what those
flags are applicable to (customers, properties, etc). - linking tables indicating a given item has a given flag attached.
- the appropriate entities tables
User Interface
I would like some of the functionalities be similar to that of stack overflow’s such as the add and removing of tags. Maybe use jquery tag-it for this? Mainly, I would like the user to be able to select the flag from a drop down list and a flag icon display when one or more flags have been selected. Mousing over the flag should show a tooltip listing the flags attached to that item. Not sure if this setup of the one flag show all be good for querying purposes as opposed to displaying multiple flags.
Sample visual: http://i232.photobucket.com/albums/ee2/nismomatic97/flag.png
Your main problem is that you have a flag record for any number of possible different entities, and not a single entity (like “customers.”).
In the past, I have solved this problem by providing an additional
Foreign Keyfield in each table (“FlagID”) that is unique across the entire database. A GUID is suitable. Then you can simplyJOINthe table that applies to your particular context to the FlagID in your Flags table, and you will get only the flags that apply to that particular entity.For example, when you
JOINFlagID in the Flags table to the FlagID in your Customers table, you get only those flags that pertain to Customers.Note that Stack Overflow doesn’t have the “Multiple Entities” problem; all flags are cast to Posts.