title: sqlite transform tree table (hierarchical) into a flat one
body: <p>I'm quite stuck with this problem here and will highly appreciate any help. 
  I need to transform a tree table / hierarchical like this:</p>
  
  <pre><code>id    name    parent
   1     aaa          
   2     bbb         1
   3     ccc         1
   4     ddd         2
   5     eee         2
   6     fff         5
  </code></pre>
  
  <p>Where<br>
  id - is a unique identifier<br>
  parent - is the id of a parent item to which a given record relates<br></p>
  
  <p>The above table needs to get transformed from a deep hierarchy into a flat horizontal table like the one below, where <code>parent</code> column is flattened and spread across multiple columns which show hierarchy from left to right:</p>
  
  <pre><code>parent  descendent_1  descendent_2   descendent_n+1     id    name   
    null          null          null              ...      1     aaa                 
       1          null          null              ...      2     bbb                
       1          null          null              ...      3     ccc         
       1             2          null              ...      4     ddd         
       1             2          null              ...      5     eee         
       1             2             5              ...      6     fff         
  </code></pre>
  
  <p>The deepness may vary from record to record.
  Here is an example of a data set:</p>
  
  <pre><code>CREATE TABLE table_1 (id int, name text, parent int);
  
  INSERT INTO table_1 VALUES
  (1,'aaa',null),
  (2,'bbb',1),
  (3,'ccc',1),
  (4,'ddd',2),
  (5,'eee',2),
  (6,'fff',5),
  (7,'ggg',6),
  (8,'hhh',7),
  (9,'iii',3),
  (10,'jjj',3),
  (11,'kkk',8),
  (12,'lll',11);
  </code></pre>
  
  <p>Thanks a million!</p>