title: How can I generate big data sample for Postgresql using generate_series and random?
body: <p>I want to generate big data sample (almost 1 million records) for studying tuplesort.c's polyphase merge in postgresql, and I hope the schema as follows:</p>
  
  <pre><code>CREATE TABLE Departments (code VARCHAR(4), UNIQUE (code));
  CREATE TABLE Towns (
    id SERIAL UNIQUE NOT NULL,
    code VARCHAR(10) NOT NULL, -- not unique
    article TEXT,
    name TEXT NOT NULL, -- not unique
    department VARCHAR(4) NOT NULL REFERENCES Departments (code),
    UNIQUE (code, department)
  );
  </code></pre>
  
  <p>how to use generate_series and random for do it? thanks a lot!</p>