What you are proposing is a sort of two-phase commit which would work but I don't think it's necessa
What you are proposing is a sort of two-phase commit which would work but I don't think it's necessary. I can think of two alternatives. sqlite (and I assume D1) has a "function"
last_insert_rowid() https://www.sqlite.org/c3ref/last_insert_rowid.html. That would allow you to insert one child with the parent. If you really want to insert more than one, then do the child inserts into a temporary table and delete as you move over to the real child table. I'm sure you could find an example of this on Stack Overflow. The second alternative would be to use a GUID that you generate client-side for your primary key. That doesn't take advantage of SQLite's really cool auto-increment rowid capability but that's really a nice-to-have.




