You can use TRANSACTION or INSERT_LAST_ID. When you want to insert data in multiple tables those two are useful. I can't provide a sample snippet for better understanding but I am sure you can find huge samples when you do a research. The difference between the 2 that I don't know.