sql - audit table vs. Type 2 Slowly Changing Dimension -
sql - audit table vs. Type 2 Slowly Changing Dimension -
in sql server 2008+, we'd enable tracking of historical changes "customers" table in operational database.
it's new table , our app controls writing database, don't need evil hacks triggers. instead build alter tracking our business object layer, need figure out right database schema use.
the number of rows under 100,000 , number of changes per record average 1.5 per year.
there @ to the lowest degree 2 ways we've been looking @ modelling this:
as type 2 changing dimension table called customershistory
, columns effectivestartdate
, effectiveenddate
(set null
current version of customer), , auditing columns changereason
, changedbyusername
. we'd build customers
view on table filtered effectiveenddate=null
. parts of our app query using view, , parts need history-aware query underlying table. performance, materialize view and/or add together filtered index on effectiveenddate=null.
with separate audit table. every alter customer
record writes 1 time customer
table , 1 time again customerhistory
audit table.
from quick review of stackoverflow questions, #2 seems much more popular. because db apps have deal legacy , rogue writers?
given we're starting blank slate, pros , cons of either approach? recommend?
in general, issue scd type- ii is, if average number of changes in values of attributes high, end-up having fat dimension table. growing dimension table joined huge fact table slows downwards query performance gradually. it's slow-poisoning.. don't see impact. when realize it, it's late!
now understand create separate materialized view effectiveenddate = null
, used in of joins. additionally you, info volume comparatively low (100,000). average changes of 1.5 per year, don't think info volume / query performance etc. going problem in near future.
in other words, table slowly changing dimension (as opposed rapidly changing dimension - alternative #2 improve fit). in case, prefer alternative #1.
sql sql-server-2008 data-modeling dimensional-modeling scd
Comments
Post a Comment