问题
The work flow for something is as follows
1) Create a "Message of the Day" for a particular group of users (which must be approved before active)
2) Assign who can approve this by selecting single users, and/or users who are admins of the group this MOTD is going into, or any other number of groupings for users.
3) "Message of the Day" must no be approved by one of the 'approvers' selected.
How can I relate a MOTD record, to one or more of "single users" and/or "groupings of users"
回答1:
One way is to add a type field to a mapping table. This works for many-to-many of different types.
create table motd_approvers (
id int auto_increment primary key,
motd_id int not null,
user_id int not null,
user_type enum('admin','user') not null
);
I don't think it's actually a one-to-many. You have many MOTD entries and many users who can be approvers for many MOTD entries.
来源:https://stackoverflow.com/questions/9900793/database-design-one-to-many-of-different-types