title: What is the best way to represent/design groups and members in a database
body: <p>Suppose that Group and Member are two java objects. Each Member occurs only once in a Group, a Group has zero or more Members. The attributes of these two objects are almost the same. A Member, however, inherits its values from the Group that it belongs to. But the values of the member can be overwritten as well.</p>
  
  <p>What is the best way to design this in a database? The only thing I can think of is to have two tables that represent these two objects. But this mean that the member table contains many similar values.</p>
  
  <pre><code>Group table
  id| attr1  | attr2  |
  ---------------------
  1 | value1 | value2 |
  
  
  Member table
  id| attr1  | attr2  | group_id | attr3 |
  ----------------------------------------
  1 | value1 | value2 | 1        | foo   |
  2 | bar    | value2 | 1        | foo   |
  </code></pre>
  
  <p>As you can see the member 1 has "inherited" its values from group 1 and has its own attr3 value <code>foo</code>. Member 2 also "inherited" values from group 1 but its attr1 value has been overwritten by <code>bar</code>.</p>