title: database table schema to store object-like dynamic attribute
body: <p>I have a simple YAML.</p>
  
  <pre><code>- name: name_1 
    k1: v1_1 
    k2: v2_1 
    k3: v3_1
  - name: name_2 
    k1: v1_2 
    k2: v2_2 
    k3: v3_2
  - name: name_3
    k1: v1_3 
    k2: v2_3 
    k3: v3_3
  </code></pre>
  
  <p>The attributes' name might vary by different projects. </p>
  
  <p>I want to put this yaml data to sqlite database. So, I create two table: <code>obj</code> and <code>attr</code> </p>
  
  <pre><code>Table:obj
  
  obj_id      name      
  ----------  ----------
  1           name_1    
  2           name_2    
  3           name_3    
  
  Table: attr
  
  id          obj_id      key         value     
  ----------  ----------  ----------  ----------
  1           1           k1          v1_1      
  2           1           k2          v2_1      
  3           1           k3          v3_1      
  4           2           k1          v1_2      
  5           2           k2          v2_2      
  6           2           k3          v3_2      
  7           3           k1          v1_3      
  8           3           k2          v2_3      
  9           3           k3          v3_3      
  </code></pre>
  
  <p>And I want to have output like the bellowing: </p>
  
  <pre><code>obj_id      name        k1          k2          k3        
  ----------  ----------  ----------  ----------  ----------
  1           name_1      v1_1        v2_1        v3_1      
  2           name_2      v1_2        v2_2        v3_2      
  3           name_3      v1_3        v2_3        v3_3      
  </code></pre>
  
  <p>I use this query:</p>
  
  <pre><code>select * 
  from 
      obj 
      natural join (select obj_id, value as k1 from attr where key = 'k1' ) 
      natural join (select obj_id, value as k2 from attr where key = 'k2' ) 
      natural join (select obj_id, value as k3 from attr where key = 'k3' ) 
  ;
  </code></pre>
  
  <p>This could generate the output, quite a lot of words. 
  Moreover, in another project, attribute names may change, let's say the attribute might be  (k4, k5, k6). 
  I have to re-write this query again. </p>
  
  <p>I have two questions:</p>
  
  <ol>
  <li>Any better query syntax to make this more elegant? </li>
  <li>Any better query syntax let query suitable for any projects which key may vary?</li>
  </ol>