For each record in the resultset Get the fields For each field which is an auto-increment, record that we exported that key For each field which references a foreign key, If we want to 'inline' that relation, follow the relation and get its data too insert that data under the relation name of this data else if we are also saving the related object, Tell the exporter that we depend on it else build a search so that we can join up to it if the IDs of the new DB are different