I have a database design question.

Asked 2 years ago, Updated 2 years ago, 47 views

I have a question about configuring the database

ex)
Product Table
code/name/specification/price
---------------------------------
a0001 / a / a-101 / 10000
...
..
.

For example, how can we organize these tables and keep and query old data when prices change from March 1, 2019?

ex)
2018-01-01 - 2019-02-28 a0001 Code Total 100 = 1,000,000
2018-03-01 ~ 2020-12-31 a0001 Code Total 100 pieces = 1,100,000 (Change to amount 11000)

★2018-01-01-01 ~ 2019-03-31 a0001 Code Total 100 (10 of March) = 1,230,000
# 2018-01-01-01 to 2019-02-28 90 pieces 90000
# 2018-03-01 ~ 2019-03-31 10 pieces 33000

If you put all the values in the table and change the price later, the value changes and is more than updated. In this case, I think you should divide it into values that are as dependent as normalization and paste it with join, but it doesn't work well... I don't know if it's the right way to do it, but if you look at the ;; company db, it seems like it's just putting everything in and using it, so please give me advice. ㅜ<

;;;;

database sql

2022-09-22 10:53

2 Answers

It's right to separate the schemas

Product Master

Product code (pk), product name, specification

Product unit price

Product code (fk), date, unit price

As above, the product master and unit price should be 1 to N structure. The unit price will change depending on the date, so it is easy to manage the history if you leave the changed item in a form that is added without modifying the item.

In fact, if detailed options are divided according to the product, the specification part should also be separated.


2022-09-22 10:53

If I share what I saw...


2022-09-22 10:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.