M
M
Maxim Vorotnikov2017-02-06 14:23:37
Database
Maxim Vorotnikov, 2017-02-06 14:23:37

How to correctly determine the relationship between database tables?

Good day to all! I read a lot of information on determining relationships between database tables, but my case causes me difficulties.
There is a table with goods: c65a4ad63f5844609e8eb2757eca083b.png
There is also a sales table: 94742c36cc404af0ae0e5da8e2379905.png
The system does not take into account the buyers themselves, because this is for an application for internal use in the store, but it is important which seller sold the goods (therefore seller_id is a foreign key id (user_id)).
Question:how to create a connecting table between products and orders (and is it necessary), if, in fact, a specific order (receipt) can contain not only a different product, but also a different quantity of each of the products? How to organize such a connection? Where to store the column with the quantity of each item? Each record in the sales table is, in fact, a specific receipt with goods and its own identifier. How, then, is insert performed when placing a new order?
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question