Insert Multiple Parent and Child Records with External Id
I was referring this "Creating Parent and Child Records in a Single Statement Using Foreign Keys" page and thought, what if I get a requirement to insert multiple parents and child records in a single insert statement.
I have prepared a code snippet to insert multiple Account and Contact records in a single statement.
I have also created External Id at Account object to create reference from Contact record.
Querying the newly created account and contact will display the results like this:
Under each account record, there will be a contact record.