How to get a surrogate key value in order to put a foreign key in and create relationship?
Assuming your surrogate keys are auto-incrementing integers marked as primary keys they will be the "rowid" for that table so you can read the last value added for a single insert using SELECT last_insert_rowid(). This operates like scope_identity in other databases. You would need to read each one after each row insert as each will replace record of the previous one.

sqlite doesn't seem to have an equivalent to the OUTPUT clause found in SQL Server and the RETURNING clause in Postgres &amp; Oracle, so I don't know of a way to read multiple generated ID meaning that you'll have to do this one row at a time.