Presentation on theme: "CSS Data Warehousing for BS(CS)"— Presentation transcript:
1CSS Data Warehousing for BS(CS) Lecture 1-2: DW & Need for DWKhurram ShahzadDepartment of Computer Science
2Course ObjectivesAt the end of the course you will (hopefully) be able to answer the questionsWhy exactly the world needs a data warehouse?How DW differs from traditional databases and RDBMS?Where does OLAP stands in the DW picture?What are different DW and OLAP models/schemas? How to implement and test these?How to perform ETL? What is data cleansing? How to perform it? What are the famous algorithms?Which different DW architectures have been reported in the literature? What are their strengths and weaknesses?What latest areas of research and development are stemming out of DW domain?
3Course Material Reference Books Course Book Paulraj Ponniah, Data Warehousing Fundamentals, John Wiley & Sons Inc., NY.Reference BooksW.H. Inmon, Building the Data Warehouse (Second Edition), John Wiley & Sons Inc., NY.Ralph Kimball and Margy Ross, The Data Warehouse Toolkit (Second Edition), John Wiley & Sons Inc., NY.
4Assignments Implementation/Research on important concepts. To be submitted in groups of 2 students.IncludeModeling and Benchmarking of multiple warehouse schemasImplementation of an efficient OLAP cube generation algorithmData cleansing and transformation of legacy dataLiterature Review paper onView Consistency Mechanisms in Data WarehouseIndex design optimizationAdvance DW ApplicationsMay add a couple more
5Lab WorkLab Exercises. To be submitted individually
6Course Introduction What this course is about? Decision Support Cycle Planning – Designing – Developing - Optimizing – Utilizing
7Course Introduction Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)OperationalDB’sSemistructuredSourcesextracttransformloadrefreshetc.Data MartsDataWarehousee.g., MOLAPe.g., ROLAPserveAnalysisQuery/ReportingData Mining
8Operational Sources (OLTP’s) Operational computer systems did provide information to run day-to-day operations, and answer’s daily questions, but…Also called online transactional processing system (OLTP)Data is read or manipulated with each transactionTransactions/queries are simple, and easy to writeUsually for middle managementExamplesSales systemsHotel reservation systemsCOMSISHRM ApplicationsEtc.
9Typical decision queries Data set are mounting everywhere, but not useful for decision supportDecision-making require complex questions from integrated data.Enterprise wide data is desiredDecision makers want to know:Where to build new oil warehouse?Which market they should strengthen?Which customer groups are most profitable?How much is the total sale by month/ year/ quarter for each offices?Is there any relation between promotion campaigns and sales growth?Can OLTP answer all such questions, efficiently?
10Information crisis* Integrated Data Integrity Accessible Credible Must have a single, enterprise-wide viewData IntegrityInformation must be accurate and must conform to business rulesAccessibleEasily accessible with intuitive access paths and responsive for analysisCredibleEvery business factor must have one and only one valueTimelyInformation must be available within the stipulated time frame* Paulraj 2001.
11Data Driven-DSS** Farooq, lecture slides for ‘Data Warehouse’ course
12Failure of old DSS Inability to provide strategic information IT receive too many ad hoc requests, so large over loadRequests are not only numerous, they change overtimeFor more understanding more reportsUsers are in spiral of reportsUsers have to depend on IT for informationCan't provide enough performance, slowStrategic information have to be flexible and conductive
13OLTP vs. DSS Trait OLTP DSS User Middle management Executives, decision-makersFunctionFor day-to-day operationsFor analysis & decision supportDB (modeling)E-R based, after normalizationStar oriented schemasDataCurrent, IsolatedArchived, derived, summarizedUnit of workTransactionsComplex queryAccess, typeDML, readReadAccess frequencyVery highMedium to LowRecords accessedTens to HundredsThousands to MillionsQuantity of usersThousandsVery small amountUsagePredictable, repetitiveAd hoc, random, heuristic basedDB size100 MB-GB100GB-TBResponse timeSub-secondsUp-to min.s
14Expectations of new soln. DB designed for analytical tasksData from multiple applicationsEasy to useAbility of what-if analysisRead-intensive data usageDirect interaction with system, without IT assistancePeriodical updating contents & stableCurrent & historical dataAbility for users to initiate reports
15DW meets expectations Provides enterprise view Current & historical data availableDecision-transaction possible without affecting operational sourceReliable source of informationAbility for users to initiate reportsActs as a data source for all analytical applications
16Definition of DW Four properties of DW Inmon defined “A DW is a subject-oriented, integrated, non-volatile, time-variant collection of data in favor of decision-making”.Kelly said“Separate available, integrated, time-stamped, subject-oriented, non-volatile, accessible”Four properties of DW
17Subject-orientedIn operational sources data is organized by applications, or business processes.In DW subject is the organization methodSubjects vary with enterpriseThese are critical factors, that affect performanceExample of Manufacturing CompanySalesShipmentInventory etc
18Integrated Data Data comes from several applications Problems of integration comes into playFile layout, encoding, field names, systems, schema, data heterogeneity are the issuesBank example, variance: naming convention, attributes for data item, account no, account type, size, currencyIn addition to internal, external data sourcesExternal companies data sharingWebsitesOthersRemoval of inconsistencySo process of extraction, transformation & loading
19Time variant Operational data has current values Comparative analysis is one of the best techniques for business performance evaluationTime is critical factor for comparative analysisEvery data structure in DW contains time elementIn order to promote product in certain, analyst has to know about current and historical valuesThe advantages areAllows for analysis of the pastRelates information to the presentEnables forecasts for the future
20Non-volatileData from operational systems are moved into DW after specific intervalsData is persistent/ not removed i.e. non volatileEvery business transaction don’t update in DWData from DW is not deletedData is neither changed by individual transactionsProperties summarySubject OrientedTime-VariantNon-VolatileOrganized along the lines of the subjects of the corporation. Typical subjects are customer, product, vendor and transaction.Every record in the data warehouse has some form of time variancy attached to it.Refers to the inability of data to be updated. Every record in the data warehouse is time stamped in one form or another.
22Agenda Data Warehouse architecture & building blocks ER modeling reviewNeed for Dimensional ModelingDimensional modeling & its insideComparison of ER with dimensional
23Architecture of DW Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)e.g., MOLAPAnalysisSemistructuredSourcesDataWarehouseserveextracttransformloadrefreshQuery/Reportingservee.g., ROLAPOperationalDB’sserveData MiningStaging areaData Marts
24Components Major components Source data component Data staging componentInformation delivery componentMetadata componentManagement and control component
251. Source Data Components Source data can be grouped into 4 componentsProduction dataComes from operational systems of enterpriseSome segments are selected from itNarrow scope, e.g. order detailsInternal dataPrivate datasheet, documents, customer profiles etc.E.g. Customer profiles for specific offeringSpecial strategies to transform ‘it’ to DW (text document)Archived dataOld data is archivedDW have snapshots of historical dataExternal dataExecutives depend upon external sourcesE.g. market data of competitors, car rental require new manufacturing. Define conversion
26Architecture of DW Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)e.g., MOLAPAnalysisSemistructuredSourcesDataWarehouseserveextracttransformloadrefreshQuery/Reportingservee.g., ROLAPOperationalDB’sserveData MiningStaging areaData Marts
272. Data Staging Components After data is extracted, data is to be preparedData extracted from sources needs to be changed, converted and made ready in suitable formatThree major functions to make data readyExtractTransformLoadStaging area provides a place and area with a set of functions toCleanChangeCombineConvert
28Architecture of DW Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)e.g., MOLAPAnalysisSemistructuredSourcesDataWarehouseserveextracttransformloadrefreshQuery/Reportingservee.g., ROLAPOperationalDB’sserveData MiningStaging areaData Marts
293. Data Storage Components Separate repositoryData structured for efficient processingRedundancy is increasedUpdated after specific periodsOnly read-only
30Architecture of DW Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)e.g., MOLAPAnalysisSemistructuredSourcesDataWarehouseserveextracttransformloadrefreshQuery/Reportingservee.g., ROLAPOperationalDB’sserveData MiningStaging areaData Marts
314. Information Delivery Component Authentication issuesActive monitoring servicesPerformance, DBA note selected aggregates to change storageUser performanceAggregate awarenessE.g. mining, OLAP etc
33Designing DW Information Sources Data Warehouse Server (Tier 1) OLAP Servers(Tier 2)Clients(Tier 3)e.g., MOLAPAnalysisSemistructuredSourcesDataWarehouseserveextracttransformloadrefreshQuery/Reportingservee.g., ROLAPOperationalDB’sserveData MiningStaging areaData Marts
34Background (ER Modeling) For ER modeling, entities are collected from the environmentEach entity act as a tableSuccess reasonsNormalized after ER, since it removes redundancy (to handle update/delete anomalies)But number of tables is increasedIs useful for fast access of small amount of data
35ER Drawbacks for DW / Need of Dimensional Modeling ER Hard to remember, due to increased number of tablesComplex for queries with multiple tables (table joins)Conventional RDBMS optimized for small number of tables whereas large number of tables might be required in DWIdeally no calculated attributesThe DW does not require to update data like in OLTP system so there is no need of normalizationOLAP is not the only purpose of DW, we need a model that facilitate integration of data, data mining, historically consolidated data.Efficient indexing scheme to avoid screening of all dataDe-Normalization (in DW)Add primary keyDirect relationshipsRe-introduce redundancy
36Dimensional ModelingDimensional Modeling focuses subject-orientation, critical factors of businessCritical factors are stored in factsRedundancy is no problem, achieve efficiencyLogical design technique for high performanceIs the modeling technique for storage
37Dimensional Modeling (cont.) Two important conceptsFactNumeric measurements, represent business activity/eventAre pre-computed, redundantExample: Profit, quantity soldDimensionQualifying characteristics, perspective to a factExample: date (Date, month, quarter, year)
38Dimensional Modeling (cont.) Facts are stored in fact tableDimensions are represented by dimension tablesDimensions are degrees in which facts can be judgedEach fact is surrounded by dimension tablesLooks like a star so called Star Schema
39Example TIME time_key (PK) SQL_date day_of_week month STORE store_key (PK)store_IDstore_nameaddressdistrictfloor_typeCLERKclerk_key (PK)clerk_idclerk_nameclerk_gradePRODUCTproduct_key (PK)SKUdescriptionbrandcategoryCUSTOMERcustomer_key (PK)customer_namepurchase_profilecredit_profilePROMOTIONpromotion_key (PK)promotion_nameprice_typead_typeFACTtime_key (FK)store_key (FK)clerk_key (FK)product_key (FK)customer_key (FK)promotion_key (FK)dollars_soldunits_solddollars_cost
40Inside Dimensional Modeling Inside Dimension tableKey attribute of dimension table, for identificationLarge no of columns, wide tableNon-calculated attributes, textual attributesAttributes are not directly relatedUn-normalized in Star schemaAbility to drill-down and drill-up are two ways of exploiting dimensionsCan have multiple hierarchiesRelatively small number of records
41Inside Dimensional Modeling Have two types of attributesKey attributes, for connectionsFactsInside fact tableConcatenated keyGrain or level of data identifiedLarge number of recordsLimited attributesSparse data setDegenerate dimensions (order number Average products per order)Fact-less fact table
42Star Schema Keys Primary keys Surrogate keys Foreign keys Identifying attribute in dimension tableRelationship attributes combine together to form P.KSurrogate keysReplacement of primary keySystem generatedForeign keysCollection of primary keys of dimension tablesPrimary key to fact tableCollection of P.Ks
43Advantage of Star Schema Ease for users to understandOptimized for navigation (less joins fast)Most suitable for query processingKaren Corral, et al. (2006) The impact of alternative diagrams on the accuracy of recall: A comparison of star-schema diagrams and entity-relationship diagrams, Decision Support Systems, 42(1),
44Normalization “It is the process of decomposing the relational table in smaller tables.”Normalization Goals:Remove data redundancyStoring only related data in a table (data dependency makes sense)5 Normal FormsThe decomposition must be lossless
451st Normal Form “A relation is in first normal form if and only if every attribute is single-valued for each tuple”STU_IDSTU_NAMEMAJORCREDITSCATEGORYS1001Tom SmithHistory90CompS1003Mary JonesMath95ElectiveS1006Edward BurnsCSC, Math15Comp, ElectiveS1010Art, English63Elective, ElectiveS1060John SmithCSC25
461st Normal Form (Cont.) STU_ID STU_NAME MAJOR CREDITS CATEGORY S1001 Tom SmithHistory90CompS1003Mary JonesMath95ElectiveS1006Edward BurnsCSC15S1010Art63EnglishS1060John Smith25
47Another Example (composite key: SID, Course) 
481st Normal Form Anomalies  Update anomaly: Need to update all six rows for student with ID=1if we want to change his location from Islamabad to KarachiDelete anomaly: Deleting the information about a student who has graduated will remove all of his information from the databaseInsert anomaly: For inserting the information about a student, that student must be registered in a course
49Solution 2nd Normal Form “A relation is in second normal form if and only if it is in first normal form and all the nonkey attributes are fully functional dependent on the key” In previous example, functional dependencies SID —> campusCampus degree
51Anomalies Insert Anomaly: Can not enter a program for example PhD for Peshawar campus unless a student get registeredDelete Anomaly: Deleting a row from “Registration” table will delete all information about a student as well as degree program
52Solution 3rd Normal Form “A relation is in third normal form if it is in second normal form and nonkey attribute is transitively dependent on the key” In previous example: Campus degree
54Denormalization “Denormanlization is the process” to selectively transforms the normalized relations in to un-normalized form with the intention to “reduce query processing time”The purpose is to reduce the number of tables to avoid the number of joins in a query
61Updates to Dimension Tables (Cont.) Type-I changes: correction of errors, e.g., customer name changes from Sulman Khan to Salman KhanSolution to type-I updates:Simply update the corresponding attribute/attributes. There is no need to preserve their old values
62Updates to Dimension Tables (Cont.) Type 2 changes: preserving historyFor example change in “address” of a customer, but the user wants to see orders by geographic location then you can not simply update the address by replacing old value with new value, you need to preserve the history (old value) as well as need to insert new value
63Updates to Dimension Tables (Cont.) Proposed solution:
64Updates to Dimension Tables (Cont.) Type 3 changes: When you want to compare old and new values of attributes for a given periodPlease note that in Type 2 changes the old values and new values were not comparable before or after the cut-off date (when the address was changed)
65Updates to Dimension Tables (Cont.) Solution: Add a new column of attribute
66Updates to Dimension Tables (Cont.) What if we want to keep a whole history of changes?Should we add large number of attributes to tackle it?
67Rapidly Changing Dimension When dimension’s records/rows are very large in numbers and changes are required frequently then Type-II change handling is not recommendedIt is recommended to make a separate table of rapidly changing attributes
68Rapidly Changing Dimension (Cont.) “For example, an important attribute for customers might be their account status (good, late, very late, in arrears, suspended), and the history of their account status” “If this attribute is kept in the customer dimension table and a type 2 change is made each time a customer's status changes, an entire row is added only to track this one attribute” “The solution is to create a separate account_status dimension with five members to represent the account states”  and join this new table or dimension to the fact table.
70Junk DimensionsSometimes there are some informative flags and texts in the source system, e.g., yes/no flags, textual codes, etc.If such flags are important then make their own dimension to save the storage space
78SolutionMake aggregate fact tables, because you might be summing some dimension and some might not then why we should store the dimensions that do not need highest level of granularity of details.For example: Sales of a product in a year ORtotal number of items sold by category on daily basis