title: How to copy/insert multiple rows of data to implement many to many relationship in postgres
body: <p>I have the following tables in Postgres: questions, responses and question_response. There is a many to many relationship between questions and responses. </p>
  
  <h1>questions.sql</h1>
  
  <pre><code>CREATE TABLE questions( 
      id BIGSERIAL PRIMARY KEY,
      question VARCHAR(255)
  );
  </code></pre>
  
  <h1>respones.sql</h1>
  
  <pre><code>CREATE TABLE responses( 
      id BIGSERIAL PRIMARY KEY,
      response VARCHAR(255)
  );
  </code></pre>
  
  <h1>question_respone.sql #</h1>
  
  <pre><code>CREATE TABLE question_response(
      question_id bigint REFERENCES questions ON DELETE CASCADE,
      response_id bigint REFERENCES responses ON DELETE CASCADE,
      PRIMARY KEY ( question_id, response_id)
  );
  </code></pre>
  
  <p>I have the following data in questions table</p>
  
  <pre><code>id | question
   1   Rate the effectiveness of the program?
   2   Rate the ease of learning?
   3   Rate the duration ?
   .....
  // there are a list of 20 questions 
  </code></pre>
  
  <p>and in responses table</p>
  
  <pre><code>id | response
   100   Poor
   200   Average
   300   Good
   400   Excellent
  </code></pre>
  
  <p>How do I write a query of function in Postgres to insert the following data in question_response table.</p>
  
  <pre><code>question_id | response_id
  
           1   100
           1   200
           1   300
           1   400
           2   100
           2   200
           2   300
           2   400
           3   100
           3   200
           3   300
           3   400
           4   100
           4   200
           4   300
           4   400
          ......... etc for all 20 questions
  </code></pre>