6
6
666Wolf6662016-03-08 12:21:22
SQL
666Wolf666, 2016-03-08 12:21:22

What is the best way to make a table?

The next dilemma was the table, everything functioned OK and now it also works, but due to its inexperience, I did the following.
The "Goods" table has a "Warehouse" column, which contains the id of the warehouse where the goods are located. When creating the same product in another warehouse, another record is created in the table (it is duplicated, but only the warehouse id is changed). I have 3 warehouses and so there are 3 records in the goods table for one product. In fact, there are not many goods, it is convenient to sort and keep records under different accounts. Since each seller has his own account and accesses are registered in this account.
But now I have one question. Did I do the right thing? Maybe it would be better to create in the product table not a warehouse id, but for each warehouse to select a column with the amount of goods in stock? Maybe someone will tell you how best to do it and how to do it in general in such cases. While the base is not completely filled and there is an opportunity to redo it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2016-03-08
@666Wolf666

Of course , there should be three tables: goods, warehouses and goods-warehouse. The last table simply stores the link between the product and the warehouse (maybe more quantity).

I
Ivan Ivanov, 2016-03-09
@kolobok_11

That's right , a many-to-many relationship between the Warehouse and Product tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question