Unanswered: Insert Records in a two tables with many-to-many relationship.
Hi, i have a dude and i expect that someone here can resolve it:
I have one table of products and a table of suppliers and they are relationed with a many-to-many relationship. Therefore i have a third table (junction table) that contains the pks of each one and the quantitie of product. My dude consists when i insert a new record for a new product, how manage the junction table?? Manually with code i'll insert a new record with both keys (new product and supplier that provides it to me) too and the quantitie or the dbms do that automatically??
I would do it as a separate statement. When you add a new product, there isn't any way I understand to predict which supplier(s) might be able to supply it, much less which supplier(s) actually supply that product. That is a decision that I'd leave to human intervention.
Ok, thanks, that was my dude. So, in two statements i insert the two records, one in the products table with product's info (product key, product name, etc) and one in the product details with the product key, the supplier key and the quantitie. It's correct??