If I like to insert something into a table 'things' and a first reference to it in another table 'thing_tags', how can I make sure this is atomically done?
Using two queries, I would do it like this:
INSERT INTO things(thing) VALUES("a thing");
INSERT INTO thing_tags(thing_id,tag) VALUES(SELECT MAX(rowid) FROM things), "a default tag");
However, this makes to queries, I am not sure if some other query could go inbetween, and it looks useless complicated. Is there a simple and clean way to insert the tag referencing the new thing?