Database architecture - Have 2 seperate columns or 1 -
okey, context:
i have system requires monthly, weekly , dayly reports.
architecture a: 3 tables: 1) monthly reports 2) weekly reports 3) daily reports
architecture b: 1 table: 1) reports: column report_type
, values: "monthly", "weekly", "daily".
which 1 more performant , why?
the common method use use 2 tables, following b approach. 1 table describe report data , column, instead of hard coding values, column hold id reference table. reference table hold names of these values. set allows reference intervals other tables should need later on, makes name updates more efficient. changing name of "monthly" "month" require 1 update here, vs n updates if stored string in report table.
sample structure:
report_data | interval_id xxxx | 1 interval_id | name 1 | monthly
as side note, want take first approach, approach a, due how limits changing interval type of entered data. if of sudden want change half of daily entries weekly entries, need n/2 deletes , n/2 inserts, costly if start introducing indexes. in general tables should describe types of data (ie reports) , columns should describe type (ie how report happens)
Comments
Post a Comment