title: SQL - Creating a table with the name as a result of a query
body: <p>Is it possible to create a table in SQL with the following requirements.</p>
  
  <p>I have a table X with two cols, (primary key, value)</p>
  
  <p>Every time, I add a new value to the above table, I create a new table with the name value.</p>
  
  <p>So if there are 10 rows in table X, then we need to have 10 tables with names in the values field.</p>
  
  <hr>
  
  <p>Let me try to explain the situation.
  I have a category A and I need to define it.
  The subsets of A can include {a1, a2, a3, ..... until infinity}</p>
  
  <p>All the subsets have a different definition but are uniquely identified a property B.</p>
  
  <p>B can be directly A, or a subset A with the definition holding true. I am not sure how to design it. I am using postgresql</p>
  
  <hr>
  
  <p>So I am taking cues from  a_horse_with_no_name and think that this can be a table structure.<div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Table A 
  &lt;table border="1"&gt;
    &lt;td&gt; primary_key &lt;/td&gt;
    &lt;td&gt; B1 &lt;/td&gt;
    &lt;td&gt; B2 &lt;/td&gt;
    &lt;td&gt; hstore - attribute &lt;/td&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Now what store should act like is similar to a tree.</p>
  
  <p>hstore - attribute -> { a1 : {c1,c2,c3...}, a2 :{d1,d2,d3..}, .... } </p>
  
  <p>C and D are structures here with multiple or single values. So if I am to use an hstore, is it possible to use something like a 2d array or something similar. It seems that it is possible from the following link. </p>
  
  <p><a href="http://www.postgresql.org/docs/9.0/static/hstore.html" rel="nofollow">http://www.postgresql.org/docs/9.0/static/hstore.html</a></p>
  
  <p>I think this is certainly a better approach. Can you please check and comment.
  and so on.. </p>