Go Back   CORTEX Forums > Local Happenings > CORTEX Blogs > I SQL
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

Implementing an Agile ETL process is SQL Server

This is a discussion on Implementing an Agile ETL process is SQL Server within the I SQL forums, part of the CORTEX Blogs category; I was fortunate enough recently to attend the DW 2.0 Conference in Sydney. One of the presenters, Therese Ahlstam (from the Genesee Academy) advocated a technique for building data warehouse's ...


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11th November 2011, 02:46 PM   #1
Member
 
Join Date: Jul 2009
Posts: 44
Leigh Kennedy is on a distinguished road
Default Implementing an Agile ETL process is SQL Server

I was fortunate enough recently to attend the DW 2.0 Conference in Sydney. One of the presenters, Therese Ahlstam (from the Genesee Academy) advocated a technique for building data warehouse's she referred to as Hyper-agility. The idea was to avoid the need to constant schema changes by storing Staging & ODS tables as Key/Value pairs. To me this seems to fit the Serialisation/de-serialisation design pattern so common in many software frameworks these days.

This idea seemed quite radical to me, but I've been thinking on this ever since and I decided to have a look at how feisible this really is. As it turns out, while the syntax is a bit tricky, this is not only possible but relatively easy to do in MS SQL Server thanks to the PIVOT/UNPIVOT commands.

Here is an example:

CREATE TABLE SourceTable
(pkID int,
Name VARCHAR(50),
Address VARCHAR(250),
Phone VARCHAR(30)
)
GO


INSERT INTO SourceTable VALUES (1,'Bob Smith', '1 Miller St Sydney', '555-1234');
INSERT INTO SourceTable VALUES (2, 'John wayne', '10 california Dr Hollywood', '+1-555-4567');
INSERT INTO SourceTable VALUES (3,' Billy Bowden', '4 Wainui road Wellington', '+64-21-3456789');
GO


--Unpivot the table.
SELECT pkID, KeyCol, ValCol INTO unpivotSourceTable
FROM
(SELECT pkID, CAST(Name as VARCHAR(250)) as Name,Address,cast(Phone as VARCHAR(250)) as Phone from SourceTable) ST
UNPIVOT
(ValCol FOR KeyCol IN (Name,Address,Phone)
)AS uST
GO


select * from unpivotSourceTable
ORDER BY pkID, KeyCol

pkID KeyCol ValCol
1 Address 1 Miller St Sydney
1 Name Bob Smith
1 Phone 555-1234
2 Address 10 california Dr Hollywood
2 Name John wayne
2 Phone +1-555-4567
3 Address 4 Wainui road Wellington
3 Name Billy Bowden
3 Phone +64-21-3456789

Note we need to convert all the columns to the same data type to get this to work (which makes sense) . This is how we would store the data in our Operational data store and/or staging database.

But how do we get back to a regular row when we need it ? We pivot it !

SELECT pkID, [Name],[Address],[Phone]
FROM
(select pkID, KeyCol, ValCol FROM unpivotSourceTable) uST
PIVOT
(MIN(ValCol) for KeyCol in ([Name],[Address],[Phone]) )as pST




pkID Name Address Phone
1 Bob Smith 1 Miller St Sydney 555-1234
2 John wayne 10 california Dr Hollywood +1-555-4567
3 Billy Bowden 4 Wainui road Wellington +64-21-3456789




Do you think there is value in this approach ? I've yet to put it into practice, but if you have, let me know. I'd be a bit concerned about the performance for very large tables, but I can see how this would speed up development.







Get More from the original blog...
Leigh Kennedy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiTweet this Post!
Reply With Quote
Reply

Bookmarks

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Senior WebSphere Process Server Developer | Long term contract | Melbourne admin Local SAP Job Listings 0 19th September 2011 05:41 PM
Re-implementing udf_init_error in MySQL 5.5 and up Latest News Headlines DWH Tip Feeds 0 25th August 2011 09:07 AM
50 Best Practices For Implementing Mobile CRM Latest News Headlines Forrester 0 24th August 2011 03:01 AM
Agile, Agile, Agile - You Path to Agile SOA - Part 5 (final) Latest News Headlines Oracle News and Views 0 25th November 2009 11:17 AM
Agile, Agile, Agile - Our Technology - Part 4 Latest News Headlines Oracle News and Views 0 25th November 2009 11:17 AM


All times are GMT +11. The time now is 02:57 AM.

© The Business Intelligence Group

Search Engine Optimization by vBSEO