D
D
Dmitry2016-01-04 23:23:07
PHP
Dmitry, 2016-01-04 23:23:07

How to fill in related tables correctly?

Hello, I would like to know if my thinking is correct.
There is a MySQL database there 2 tables:
Order (Order number, Product number)
Product (Item number, Name, price)
The program itself is in C # and there I have a list in the ComboBox that gives the type of product (vegetables, fruits ...)
These tables are connected and I need to write in the database to the order table the number of goods from the goods table.
For example , the
Product table (1, vegetables) (2, fruits)
In the program, vegetables are selected and the Order table needs to be written (1,1)
I think to do this: in php I send the text of what I have chosen, then I look for the text of the product in the Product table and write his number. And then I insert the number into the Order table.
In my opinion this is a working option, but it seems to me there are more convenient ways.
Tell me if I'm doing it right or give advice on how to do it better, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Artemyev, 2016-01-05
@Vitaly48

Here is a good article on Habré .
I hope she helps you. And you can also see how the databases of well-known CMS, such as Opencart, are arranged.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question