title: Which is a good design for a database table that can be owned by two different resources, and therefore needs two different foreign keys?
body: <p>My application has notification settings for users that can belong to groups. A group administrator can define settings for the entire group, so that when any user performs an action, the administrator is notified. The administrator can also define settings for an individual user, which will override the group setting.</p>
  
  <p>Right now I have a database with columns: <code>group_id, action1, action2, action3, ...</code>. The actions are booleans that determine if the administrator is notified when that action is performed by a user in his or her group.</p>
  
  <p>I could make a separate table owned by the User model instead of the Group model, but it feels inefficient to store the exact same data in an entirely separate table save changing the <code>group_id</code> to <code>user_id</code>.</p>
  
  <p>Another option is to add <code>user_id</code> to the table I already have, and allow null values for <code>group_id</code>. When determining notification settings for a User, the application would first choose the setting based on User, and fallback to the setting where <code>group_id</code> is not null. This feels inefficient because there will be many null values in the database, but it definitely requires less work on my part.</p>
  
  <p>Is there a design for this situation that is more efficient than the two I've described?</p>