title: get the root parent node using neo4j
body: <p>I've imported a csv file to neo4j and created nodes and relationships for them.</p>
  <p>In the above the first two nodes comes under db1 and last four nodes comes under db2.
  How to find that last four nodes belongs to db2?</p>
  <p>Below is the code and csv file
  columnname,tablename,databasename,systemname
  abc,1a,db1,Finance
  def,1a,db1,Finance
  ghi,1a,db1,Finance
  klm,1a,db1,Finance
  abc,1a,db2,Medical
  def,1a,db2,Medical
  ghi,1a,db2,Medical
  klm,1a,db2,Medical
  nop,1a,db2,Medical
  qrs,1a,db2,Medical</p>
  <pre><code>I've created nodes and relationships for the above csv file in neo4j
  This is for getting unique values   
      CREATE CONSTRAINT ON (c:ColumnName) ASSERT c.ColumnName IS UNIQUE;
      CREATE CONSTRAINT ON (c:TableName) ASSERT c.TableName IS UNIQUE;
      CREATE CONSTRAINT ON (c:DatabaseName) ASSERT c.DatabaseName IS UNIQUE;
      CREATE CONSTRAINT ON (c:SystemName) ASSERT c.SystemName IS UNIQUE;
  
  This is for loading csv file and creating nodes and relationships
  
      LOAD CSV WITH HEADERS FROM &quot;file:///test.csv&quot; AS line
      MERGE (ColumnName:ColumnName {ColumnName: line.ColumnName})
      MERGE (TableName:TableName {TableName:line.TableName})
      MERGE (DatabaseName: DatabaseName {DatabaseName:line.DatabaseName})
      MERGE (SystemName: SystemName {SystemName:line.SystemName})
  
  This is creating relationships among the nodes
       MERGE (ColumnName)-[:iscolumnof]-&gt;(TableName)
       MERGE (TableName)-[:istableof]-&gt;(DatabaseName)
       MERGE (DatabaseName)-[:isdatabaseof ]-&gt;(SystemName)
       
   If, i select one node 'nop'and expand i'll get the node(1a) 1a and if i expand 1a i'll get all the 
  nodes(columns). How to find that 'nop' belongs to 'db2'?
  </code></pre>
  <p><a href="https://i.stack.imgur.com/kF5Sp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kF5Sp.png" alt="csv file" /></a></p>