title: Inheritance and Relationship in PostgreSQL
body: <p>I have some problems with SQL-code.</p>
  
  <p>Sequences and tables creation, some data inserting in: </p>
  
  <pre><code>CREATE SEQUENCE tmp_id_places START 1;
  CREATE SEQUENCE tmp_id_books START 1;
  
  CREATE TABLE tmp_places (
    id int PRIMARY KEY DEFAULT nextval('tmp_id_places'),
    name text
  );
  
  CREATE TABLE tmp_cities (population int) INHERITS (tmp_places);
  CREATE TABLE tmp_rivers (lenght int) INHERITS (tmp_places);
  
  INSERT INTO tmp_cities (name, population) VALUES
    ('Moscow', 15),
    ('St. Petersburg', 9);
  
  INSERT INTO tmp_rivers (name, lenght) VALUES
    ('Volga', 115),
    ('Angara', 319);
  
  CREATE TABLE tmp_books (
    id int PRIMARY KEY DEFAULT nextval('tmp_id_books'),
    id_place int REFERENCES tmp_places(id),
    title text
  ); 
  </code></pre>
  
  <p>Вut this code make an error:</p>
  
  <pre><code>INSERT INTO tmp_books (title, id_place) VALUES
    ('Some book about Moscow', 1),
    ('Another book about Angara', 4);
  </code></pre>
  
  <p>Table <strong>tmp_books</strong> contain information about places. But I can't insert data in it, because there aren't any data in master-table <strong>tmp_places</strong> (all data in child-tables). </p>
  
  <p>So can this  been resolved anyway? </p>