Imagine I have the following database structure:
- product_id in Products table is Auto-Increment
How can I Insert something in the Products table and either Amazon_Books or Starbucks_Products without losing track of the product_id?
My first thought (let's say for an Amazon_book):
- insert product information in Products table. Auto-increment is generated.
- get the max product_id
- insert in Amazon_Books the max(product_id) of products and then the amazon book information
But, what if two or more products are inserted almost in the same time? My max(product_id) could get incremented and the subtype insertion would go for something else.
Thanks.