title: How can I SELECT DISTINCT on one (excluded) column, but include other columns in the query? (ORACLE)
body: <p>So I have data arranged loosely like this:</p>
  
  <p>Table 1 - PEOPLE: person_id (primary key), parent_id, child_id, other_parent_fields, other_child_fields</p>
  
  <p>Table 2 - PARENTS: parent_id (auto incrementing primary key), other_fields
  Table 3 - CHILDREN: child_id (auto incrementing primary key), parent_id(foreign key referencing PARENTS) other_fields</p>
  
  <p>I want to be able to query for all of the distinct parents from the PEOPLE table, and insert all of the other_parent_fields into the PARENTS table, throwing out the old parent_id from Table 1, in favor of my auto incrementing parent_id in table 2.</p>
  
  <p>I also want to do the same for children, but maintain the parent-child relationships, only using my own ids from table 2 and table 3.</p>
  
  <p>Essentially, I am trying to change the way that the database is designed. Rather than a whole table for all people, I am creating a PARENTS table and a CHILDREN table, the latter of which refers to PARENTS with a foreign key. The reason I am throwing out the ids from table 1 is because I have no reason to care about them in my new table (i.e. the numbering can start back from one, and additional entries can just auto increment the primary key). However, before discarding these IDs from table 1, I need to capture the parent-child relations that they relay.</p>
  
  <p>Is this even possible? How would one go about doing it?</p>
  
  <p>we can assume, for simplicity that no children have children i.e. someone cant be a parent and a child</p>