title: Creating new table from data of other tables
body: <p>I'm very new to SQL and I hope someone can help me with some SQL syntax.  I have a database with these tables and fields,</p>
  
  <ul>
  <li><code>DATA</code>: data_id, person_id, attribute_id, date, value</li>
  <li><code>PERSONS</code>: person_id, parent_id, name</li>
  <li><code>ATTRIBUTES</code>: attribute_id, attribute_type</li>
  </ul>
  
  <p>attribute_type can be "Height" or "Weight"</p>
  
  <h2>Question 1</h2>
  
  <p>Give a person's "Name", I would like to return a table of "Weight" measurements for each children.  Ie: if John has 3 children names Alice, Bob and Carol, then I want a table like this</p>
  
  <pre><code>| date | Alice | Bob | Carol |
  </code></pre>
  
  <p>I know how to get a long list of children's weights like this:</p>
  
  <pre><code>select d.date, 
         d.value 
    from data d, 
         persons child, 
         persons parent, 
         attributes a 
   where parent.name='John' 
     and child.parent_id = parent.person_id 
     and d.attribute_id = a.attribute_id 
     and a.attribute_type = "Weight';
  </code></pre>
  
  <p>but I don't know how to create a new table that looks like:</p>
  
  <pre><code>| date | Child 1 name | Child 2 name | ... | Child N name |
  </code></pre>
  
  <h2>Question 2</h2>
  
  <p>Also, I would like to select the attributes to be between a certain range.</p>
  
  <h2>Question 3</h2>
  
  <p>What happens if the dates are not consistent across the children?  For example, suppose Alice is 3 years older than Bob, then there's no data for Bob during the first 3 years of Alice's life.  How does the database handle this if we request all the data?</p>