Adding and updating multiple tables from within one form?

Adding and updating multiple tables from within one form?

Hi, I am new here and more or less new to jquery & Ajax but I'm fairly adept with MySQL and more. Before I begin I'm trying to find a good direction to follow as I will be learning on the fly.

I basically want to be able to enter a bunch of info about an item(building) and submit it from one page.

This building will contain some basic info where there is only one value for each item, so one table will be fine for this part, but it will also contain info for items that have multiple values - this is where additional tables are needed.

e.g. the building will have the following items in a table I'll call "main"
year opened

there will always only be one value for these

for these next ones though, there can be multiple values so additional tables are needed(i do not want to add new fields to the main). These will all be names of tables

Make sense? The first table main has items where there is only one record for each building. The other tables will likely have multiple records for each building. I don't want to including a bunch of extra fields in the main table for this.

So designing the table is easy enough. What I want to do is have a front end that handles creating a database entry for a new building. Entering all the info for the main table is easy enough, but what suggestions do you have for entering data for the additional tables while still using one data entry page.

Ajax seems obvious and jQuery possibly good for this. The problem is how can you add records to the secondary tables if a record in the main table does not exist?

Should I use temporary tables? Can I simply put them into an array in jQuery and once everything is validated it creates the entry in the main table first then adds the appropriate records to the secondary table? Any way to make sure all records are inserted correctly otherwise none of them are? I'd hate to see only part of the info get inserted while other inserts fail.

Any advice is appreciated.