title: NiFi - Get record ID to insert as foreign key
body: <p>I've a data source with a table users with <code>name</code>, <code>age</code> and <code>role</code> columns. Now I need to create two tables out of it and put those into the new DB. Tables are <code>user</code> and <code>role</code>. So, first I dump data into <code>user</code> table and for the <code>role</code> column I need to insert into <code>role</code> table and put that <code>ID</code> in <code>role</code> column of <code>user</code> table. I've to do the same for each record. Check if the role record already there, if yes return <code>ID</code> or create new record and return inserted <code>ID</code>.</p>
  <p>Sample Source Data:</p>
  <pre><code>Name,age,role
  
  David,35,admin
  
  Tay,23,user
  
  John,27,user
  </code></pre>
  <p>Expected output data:</p>
  <ul>
  <li>User table:</li>
  </ul>
  <pre><code>David,35,1
  
  Tay,23,2
  
  John,27,2
  </code></pre>
  <ul>
  <li>Role table:</li>
  </ul>
  <pre><code>1,admin
  
  2,user
  </code></pre>
  <p>Please help me achieving this using NiFi</p>