title: relation tables inheritance modeling
body: <p>I want to understand inheritance in postgresql, simple whitch columns in whitch tables.</p>
  
  <pre><code>CREATE TABLE users (
    id serial PRIMARY KEY,
    username VARCHAR UNIQUE NOT NULL,
    email VARCHAR NOT NULL,
    password_salt VARCHAR,
    password_hash VARCHAR,
    avatar serial
  )
  
  CREATE TABLE groups (
    id serial PRIMARY KEY NOT NULL,
    name VARCHAR,
    email VARCHAR,
    avatar serial,
  )
  
  CREATE TABLE accounts (
    id serial PRIMARY KEY NOT NULL,
    name VARCHAR,
    avatar serial,
    rating json NOT NULL,
  );
  
  CREATE TABLE users_to_accounts (
    id serial PRIMARY KEY NOT NULL,
    start_time DATETIME NOT NULL,
    end_time DATETIME,
  )
  
  CREATE TABLE account_subscryptions (
    user_id serial NOT NULL,
    account_id serial NOT NULL,
  ) INHERITS users_to_accounts
  
  CREATE TABLE account_memberships (
    user_id serial NOT NULL,
    account_id serial NOT NULL,
  ) INHERITS users_to_accounts
  
  CREATE TABLE users_to_groups (
    id serial PRIMARY KEY NOT NULL,
    start_time DATETIME NOT NULL,
    end_time DATETIME,
  )
  
  CREATE TABLE group_subscryptions (
    user_id serial NOT NULL,
    group_id serial NOT NULL,
  ) INHERITS users_to_groups
  
  CREATE TABLE group_memberships (
    user_id serial NOT NULL,
    group_id serial NOT NULL,
  ) INHERITS users_to_groups
  </code></pre>
  
  <p>Now.<br/>
  1. Is it good design to have foreign keys in child tables an all common data in "abstract" table?<br/>
  2. Is there any traps in future changes of database with inherited relantion tables?<br/>
  3. I am all wrong and there is a better way for this schema?<br/>
  4. I want to create good database schema and generate graphql api in postgraphile, looking in google for half day, did not gave me any one good or best solution, so every link will by great.<br/><br/></p>
  
  <p>It may be usefull for others, I think. Thanks</p>