In an application I’m working on there is a select menu which has options such as Pending, Active, Inactive. I’d like to allow users to create their own custom options to include in these menus. They should be allowed to add edit and delete their own custom options but not the system defaults. What would a good normalized mysql schema look like for this?
Share
Have a look at this post and especially at this resource: http://www.billsternberger.net/jquery/dynamically-add-dropdownlist-option-using-jquery/
It’s very simple and does what you want (except for deleting, but that shouldn’t be hard to implement :))
Concerning the table structure, I’s suggest to have a table for the select entries that could have following fields:
where
added_by_userdoes not specify the user but tells if it was added by a user.And in the users table, you could add the field
select_idas a foreign key.Now you can tell, if an entry was added by a user, and if so, by which user.
That’s pretty basic, but as I said, it’s just one way of doing it (and the way I do it :)), and you get the idea.
//EDIT:
If you want a user to be able to have more than one entry, the entries table should, of course, contain the
users_idas a foreign key (and not the other way around as it is in the case above):Depending on how the
user_ids are handled (e.g. user with ID = 0 is admin or something) theadded_by_userfield might be obsolete here.