sql - simple table design question -
I am trying to think a bit further and if possible I am trying to avoid some extra pain.
I have found this problem in previous applications and are generally chosen for most verbose approaches, but others would like to have opinions.
If you have a basic table such as below, it is intelligent, and / or more efficient to include a field in which information is included in the calculation which can be found in two other columns ie:
+ ----- + --------- + ------------ + ------- + - ------ + ------- + | ID | Room_id | Bookit | Price | People | Total. + ----- + --------- + ------------ + ------- + -------- + --- ---- + | 414 | 132 | 2010-03-01 | 14.55 | 2 | 29.10 | | 415 | 132 | 2010-03-02 | 14.55 | 2 | 29.10 | | 416 | 132 | 2010-03-03 | 14.55 | 2 | 29.10 | + ----- + --------- + ------------ + ------- + -------- + --- ---- +
The information in the previous field can be removed from the product of the previous two, so it is unnecessary and unnecessary. What are the examples when it can still be?
As a rule of thumb, store values that can be calculated on the fly (especially Which can easily be calculated) unless there is a performance problem and I have to save some processing time.
This display and storage I would recommend calculating the price until you need to promote any performance.
Comments
Post a Comment