|
Can I change the table structure?
Date number
Into 11/1 1
In 11/1 2
In 11/1 3
....
In 11/1 10
Out 11/2 1
Out 11/2 2
....
On the surface, this increases the amount of data, but the business logic of the insert, update, and merge queries is the simplest and most in line with the actual situation. I guess you just need the date from the last merged report-like thing, and the previous journal table is not necessary (even if the user enters the date from the UI, insert / update is only a cycle)
Otherwise, your design can save a lot of data, but it may cause a lot of calculation problems. The actual cost performance should be lower.
such as
In 11/1 1 10
Out 11/2 10 10
In 11/2 11 15
Out 11/3 4 5
Out 11/4 1 1
Out 11/5 12 13
Out 11/6 2 3
...
Moreover, even if you can come up with an algorithm, if the business logic changes slightly, it may be overturned.
Your existing table structure algorithm is thinking ... |
|