If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Maintaining a periodic snapshot

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-09, 11:10
scorpioTiger scorpioTiger is offline
Registered User
 
Join Date: Jun 2009
Posts: 22
Maintaining a periodic snapshot

Hi folks,

I'm building a data warehouse for an insurance company and need to build a periodic snapshot so that I can provide measures such as [policies in force], [premium to date] and [premium earned].

I'm looking for best practice for maintaining the table. Transactions will have a transaction date and an effective date. The most important date for my purposes is the effective date. This means that transactions may impact previously inserted rows in the snapshot.

At this point, I'm looking inserting my new rows to the transaction grained fact table and then cursor based processing along the lines of;

for each distinct policy in the freshly staged data
__delete from snapshot table where policy = policy
__@cummulative_premium = 0
__@premium_earned = 0
__for each transaction in transaction fact table by effective date
____@cummulative_premium = @cummulative_premium + premium
____@premium_earned = premium/datediff(day,expiry_date,_effective_date)
____do while @date< [effective date for next transaction] or [expiry_date]
______insert into snapshot table
____loop
__next
next

What is considered best practice for maintaining periodic snapshots? Is there a set based solution that would be a better alternative to a cursor solution.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On