1. Trang chủ
  2. » Công Nghệ Thông Tin

SAS Data Integration Studio 3.3- P41 pptx

5 190 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 530,24 KB

Nội dung

195 CHAPTER 12 Using Slowly Changing Dimensions About Slowly Changing Dimensions 195 SCD Concepts 195 Type 2 SCD Dimensional Model 196 SCD and SAS Data Integration Studio 198 Transformations That Support SCD 198 About the SCD Type 2 Loader Transformation 199 Change Tracking Techniques 199 Selecting Columns for Change Detection 200 Generating Surrogate Keys 201 How Source Data Is Loaded a Dimension Table 202 Example: Using Slowly Changing Dimensions 204 Preparation 204 Check Out Existing Metadata That Must Be Updated 205 Create and Populate the Job 205 Add SCD Columns to the Dimension Table 206 Specify the Primary Key for the Dimension Table 207 Specify the Business Key for the SCD Loader 208 Specify the Generated Key for the SCD Loader 209 Set Up Change Tracking in the SCD Loader 210 Set Up Change Detection in the SCD Loader 211 Run the Job and View the Results 212 Check In the Metadata 213 About Slowly Changing Dimensions SCD Concepts A dimension is a category of contextual data or detail data that is implemented in a data model such as a star schema. For example, in a star schema, a dimension named Customers might associate customer data with transaction identifiers and transaction amounts in a fact table. A dimension table is a table that contains data about a particular dimension in a star schema or a snowflake schema. A primary key connects a dimension table to a related fact table. For example, if a dimension table named Customers has a primary key column named Customer ID, then a fact table named Customer Sales might specify the Customer ID column as a foreign key. 196 Type 2 SCD Dimensional Model Chapter 12 A fact table is the central table in a star schema or snowflake schema. A fact table typically contains numerical measurements or amounts and is supplemented by contextual information in dimension tables. For example, a fact table might include transaction identifiers and transaction amounts. Dimension tables could add contextual information about customers, products, and salespersons. Fact tables are associated with dimension tables via key columns. Foreign key columns in the fact table contain the same values as the primary key columns in the dimension tables. Slowly changing dimensions (SCD) is a technique for tracking changes to dimension table values in order to analyze trends. For example, a dimension table named Customers might have columns for Customer ID, Home Address, Age, and Income. Each time the address or income changes for a customer, a new row could created for that customer in the dimension table, and the old row could be retained. This historical record of changes could be combined with purchasing information to forecast buying trends and direct customer marketing campaigns. Type 2 SCD Dimensional Model Dimension tables store attribute values. Dimension tables are combined with fact tables in data structures known as star schemas or snowflakes. In these data structures, fact tables record numeric measures that are associated with events. Dimension tables record categories of attribute values that are associated with the facts. Key columns associate facts with attributes. For example, consider a star schema that consists of a fact table and several dimension tables. The fact table records product sales. As shown in the following diagram, the numeric measures in the fact table are recorded in columns for amount, date, and time. The primary key column Transaction ID uniquely identifies each row in the fact table. The foreign key columns in the fact table provide referential integrity between the fact table and the dimension tables. The foreign key values enable each fact table row to accurately reference all of the attribute values that are associated with that event. Using Slowly Changing Dimensions Type 2 SCD Dimensional Model 197 Figure 12.1 Foreign and Primary Key Columns in a Star Schema Product Sales Fact Table Customer Dimension Table Primary Key Column Amount Customer ID s229p3870892 10Jun05 John Smith Erika Clark 8.10 c209 Transaction ID Date Product ID Supplier ID Name Home Address Date of Birth F M 35000 none contractor 66000 06Jan1969 17Aug1982 c157 c209 10:45 s019p1860893 10Jun05 15.37 c157 13:01 s304p2010894 10Jun05 78.17 c486 13:35 2135 N. Main St. 27717 8220 Lincoln Rd. 27615 Elaine Jones F preferred 55000 24May1971c486 314 Upton Ave. 27712 Customer ID Gender Income Discount Time Foreign Key Columns Product Dimension Table Supplier Dimension Table The fact and dimension tables in the preceding diagram represent a valid star schema, but they do not as yet implement slowly changing dimensions. To implement Type 2 slowly changing dimensions, the dimension tables need new columns that track changes to attribute values. The following diagram shows how the columns Begin Current, End Current, and Customer Generated Key have been added to the Customer Dimension Table. The columns Begin Current and End Current establish a time line of attribute value changes for each customer. The Customer Generated Key column provides unique identifiers for each row in the Customer Dimension table. To maintain referential integrity, the new generated keys are added to the fact table after the dimension table has been loaded. 198 SCD and SAS Data Integration Studio Chapter 12 Figure 12.2 Type 2 SCD Columns in the Customer Dimension Table The previous diagram shows that customer John Smith has changed his home address three times. This information, coupled with other data in other columns (such as age and frequency of purchase), can be used in analyses. One such analysis could determine if Mr. Smith was a good candidate for a marketing campaign. SCD and SAS Data Integration Studio Transformations That Support SCD SAS Data Integration Studio provides the following transformations that can be used to implement slowly changing dimensions: Type 2 SCD Loader loads dimension tables, detects changes, tracks changes, and generates integer key values. Generated key values give the target a primary key that is not dependent on the business key in the source. For more information, see “About the SCD Type 2 Loader Transformation” on page 199. See also “Example: Using Slowly Changing Dimensions” on page 204. Lookup loads source data into fact tables using key values from dimension tables. When dimension tables are loaded beforehand, and when the dimension tables contain newly generated primary key columns, the Lookup transformation efficiently pulls those generated key columns into the fact table to maintain referential integrity. The lookup process uses the latest hashing techniques for optimal performance. Exception handling enables selective responses to missing values and missing tables. WHERE-clause filtering is available to cleanse lookup table data. Fact Table Lookup loads source data into fact tables using key values from dimension tables, in a manner that is similar to the more recent Lookup transformation. Use Fact Table Lookup instead of Lookup when you want to create and save a lookup table that you can use in subsequent transformations or jobs. Key Effective Date updates dimension tables based on changes to the business key, when change detection is unnecessary. Using Slowly Changing Dimensions About the SCD Type 2 Loader Transformation 199 Surrogate Key Generator generates unique key numbers for dimension tables, in a manner that is similar but less feature-rich than the SCD Type 2 Loader transformation. Use the Surrogate Key Generator when key generation is the sole task that is required at that point in the job. To display Help topics that illustrate how these transformations can be used in SAS Data Integration Studio jobs, follow these steps: 1 From the SAS Data Integration Studio menu bar, select Help Contents. The Help window displays. 2 In the left pane of the Help window, select Examples Process Library Examples. See the examples in the Data Transforms folder. About the SCD Type 2 Loader Transformation Use the SCD Type 2 Loader transformation to load dimension tables and track changes to dimension table values. The loader supports Type 2 slowly changing dimensions. That is, the loader populates special columns in a dimension table that indicate whether a record is current or historical. Change Tracking Techniques The SCD Type 2 Loader supports three different techniques for indicating current and historical data: effective date range, current indicator, or version number. The following display shows the Change Tracking tab in the properties window for the SCD Type 2 Loader. This tab enables you to select the technique for tracking changes. Display 12.1 Change Tracking Tab In the previous display, the technique Use beginning and end dates has been selected. The Beginning Date is the current date, and the End Date is some point in . none contractor 66000 06Jan1969 17Aug1982 c157 c209 10:45 s019p18608 93 10Jun05 15 .37 c157 13: 01 s304p2010894 10Jun05 78.17 c486 13: 35 2 135 N. Main St. 27717 8220 Lincoln Rd. 27615 Elaine Jones F preferred 55000 24May1971c486 31 4 Upton Ave. 27712 Customer. illustrate how these transformations can be used in SAS Data Integration Studio jobs, follow these steps: 1 From the SAS Data Integration Studio menu bar, select Help Contents. The Help window. was a good candidate for a marketing campaign. SCD and SAS Data Integration Studio Transformations That Support SCD SAS Data Integration Studio provides the following transformations that can be

Ngày đăng: 05/07/2014, 11:20

TỪ KHÓA LIÊN QUAN