我是设计数据库的新手,我有许多计算数据的表格。保存预先计算的数据与预先计算的数据并在检索时计算它们
劳动表
table columns | formula
labor_code
job_desc
hourly_wage
daily_wage = hourly_wage * 8
monthly_wage = hourly_wage * 208
benefit_1 = daily * (5/12)
benefit_2 = monthly_wage/12
benefit_3 = there is a range of monthly_wage for a specific value to this
benefit_4 = value given by the user
benefit_5 = value given by the user
total_hourly_rate = hourly_wage + benefit_(1-5)
total_daily_rate = total_hourly_rate * 8
total_monthly_rate = total_hourly_rate * 208
材料表
table columns | formula
material_code
material_desc
brand
unit
base_price = user input
hauling_cost = user input
labor_code
labor_type = its either ful or basic
labor_rate = if labor type == ful ? labor_rate = labor.hourly_wage : labor.total_hourly_rate
total_price = base_price + hauling_cost + labor_rate
上面给出这也将具有表和计算的数据将上述基础上的值的应用程序的未来规格的表。
我想知道哪一个更好的方法是将所有数据(包括计算的数据)保存到数据库,还是应该在检索数据后以编程方式保存预先计算的数据和计算的数据(即total_hourly_rate)?
如果我的问题不清楚请评论,以便我可以清除它。
对不起noob问题,但什么缓存计算详细? – newbie
在这种情况下,缓存仅仅是“节省”的一个花哨词,特别是针对交易空间(存储结果)的时间(计算结果)。 –