Hello everyone,
On my current web-app project, users have the ability to insert an ad with title, description, the address, linked files etc.
In SQL terms that means I'm inserting data into 5 different tables (ad, addresses, address_to_user_relation, files and log)
The way I currently proceed is linear:
Insert the address if specified within the form (address table)
Link the address to the user in the relations table
Get the addr_id and insert the ad itself (ad table)
Get the ad_id and insert links to the various files (in the files table)
Insert a first entry into the log
If an error occurs, I flag it and perform DELETE actions on all the concerned tables, then redirect back to the form. If not, then the user can see his freshly inserted ad.
I'm guessing there's a more logic/clever way to do this (perhaps using temporary tables? maybe something else?)
Any help here?
Also, through my research, I've become uncertain of how reliable IDs using auto_increment really are. Should I rather define these manually? and if so, what would be a good system?
Many thanks in advance,
Ludwig