MySQL Forums
Forum List  »  Newbie

Re: Ноw better to store large number of flags?
Posted by: Chad Bourque
Date: November 05, 2010 08:47AM

What if... Have a table for Flags that contain an id and flag name and any other information about the flag you want. You could also use the flag name as the id if you wanted, but an integer id may be a little faster on the joins. Have another table of Objects that contain an id and object name and any other information about the object you want. Then have a third table Objects_Flags that only contains the object id and the flag id with both columns being part of a compound primary key.

With this method, the Objects_Flags table would only contain a row if a flag is set on an object. To unset a flag on an object, simply delete that row. You would do the same thing for Groups by adding a Groups table and a Groups_Flags table.

All of this assumes that individual flags are set on objects as opposed on only having groups of flags set on objects. You will easily be able to determine which flags are set on an object. Also, which objects have certain flags set. Also, which objects have all flags of a certain group set. And other queries all very easily.

I hope this all translates well enough for you to understand. ;-)

HTH,
Chad
Milamade, LLC - Custom Software Development

Options: ReplyQuote


Subject
Written By
Posted
Re: Ноw better to store large number of flags?
November 05, 2010 08:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.