Well I got a little problem that I have my class diagram and I want to insert data to 5 tables that are related to each other Here I show you my tables that I have and also I will put an image of all my diagram that made this little system that I am doing but here is my problem, what happens if I want to insert data in those 5 tables that I mention starting with the first that is location to finish with ad to have no problem with foreign key etc, if I insert it so table by table in that order that I say all right, but of course I do not insert the IDs of each table because they are autoincrementales but as I pick up that id to be able to insert in the next table as a foreigner? for this I came up with the idea of making a query to the table that was inserted and pick up its id (collecting its last row inserted from the table obviously) to obtain it and put it as a foreign key of the following table that I am going to insert that requires it and so on until you insert all the tables truth. now other concerns arose other than imaginemosno that this database will insert many people data to those 5 tables also at the same time then the idea that I said earlier would not work true? because it can happen that the insertion of one person is mixed with the insertion of another person, right? or can not that case come? I believe that if true? Well, according to me, what if when picking up the id of a table (last row) but it was not that last row if not the last row (this happens because many insert at the same time) and then when inserting the other table as the foreigner id collected will insert another id that should not and so an infinite mixture. How would this problem be solved? Is there any way to insert in those 5 tables but that does not affect other insertions? I mean that when I insert these 5 tables, obviously in the order that I leave below, they are inserted as a single set so that they do not affect other insertions? and how would you do to avoid those queries to get the last id inserted, etc etc? good friends just I hope you help me since I have no idea how it would be done here in that case thank you very much. I'm doing it in php and phpmyadmin:).
location table:
id (es primary key autoincremental (entero))
direccion (varchar)
zona (varchar)
dpto (varchar)
latitud (double)
longitud (double)
table producto_inmueble:
id(primary key es autoincrementable)
precio (int)
estado (varchar)
id_ubicacion (clave foranea que se relaciona con la tabla ubicacion (id))
gallery table:
id (primary key es autoincrementable)
url(text)
id_prod_inmueble(clave foranea que se relaciona con la tabla
producto_inmueble(id))
imagen(longblob)
ruta (varchar)
table detail_home
id(primary key es autoincrementable)
..... mas atributos
id_prod_inmu(clave foranea que se relaciona con la tabla
producto_inmueble)
announcement table:
id ((entero)es primary key autoimcremental)
estado (varchar)
fecha_ini (date)
titulo (text)
descripcion (text)
id_prod_inmu (esta es foranea que se relaciona con tabla
producto_inmueble(id))
ci_cliente (es foranea se relaciona con cliente(ci))
id_deta_auncio (esta relacionado osea es foranea con la tabla
Detalle_anuncio (esta tabla es estatica)) aqui no hay problema
id_categoria ( es foranea con id de la tabla categoria que tambien es
tabla estatica)