SlideShare a Scribd company logo
1 of 39
Database keys for fact & Dimension Tables
Fact Table and Fact Types
Aggregate and Fact less
-
1
Ch Anwar ul Hassan (Lecturer)
Department of Computer Science and Software Engineering
Capital University of Sciences & Technology, Islamabad
Pakistan
anwarchaudary@gmail.com
Intro to Data warehousing
 A DBMS key is an attribute or set of an
attribute which helps you to identify a
row(tuple) in a relation(table). They allow
you to find the relation between two tables.
Keys help you uniquely identify a row in a
table by a combination of one or more
columns in that table
What are keys
 Keys help you to identify any row of data in a
table. In a real-world application, a table could
contain thousands of records. Moreover, the
records could be duplicated. Keys ensure that
you can uniquely identify a table record despite
these challenges.
 Allows you to establish a relationship between
and identify the relation between tables
 Help you to enforce identity and integrity in the
relationship.
Why we need a Key?
 DBMS has several types of Keys each have
their different functionality:
 Super Key
 Primary Key
 Candidate Key
 Alternate Key
 Foreign Key
 Compound Key
 Composite Key
 Surrogate Key
Various Keys in Database Management
System
 A superkey is a combination of columns that uniquely
identifies any rows in a table. A Super key may have
additional attributes that are not needed for unique
identification.
 A single attribute or a set of attributes that can uniquely
identify all attributes of a particular relation is called Super
key. On the other hands, a super key that is a proper subset
of another super key is called candidate key. All candidate
keys are super keys but the inverse is not true
 Example, EmpSSN and EmpNum name are superkeys.
What is the Super key?
 A column or group of columns in a table which helps us
to uniquely identifies every row in that table is called a
primary key. This DBMS can't be a duplicate. The same
value can't appear more than once in the table.
 Example, StudID
What is a Primary Key?
 All the keys which are not primary key are called an
alternate key. It is a candidate key which is currently not
the primary key. However, A table may have single or
multiple choices for the primary key.
 StudID, Roll No, Email are qualified to become a primary
key. But since StudID is the primary key, Roll No, Email
becomes the alternative key.
What is the Alternate key?
 A super key with no repeated attribute is called candidate key.
 The Primary key should be selected from the candidate keys. Every
table must have at least a single candidate key
 Example: In the given table Stud ID, Roll No, and email are
candidate keys which help us to uniquely identify the student record
in the table.
What is a Candidate Key?
 A foreign key is a column which is added to create a
relationship with another table. Foreign keys help us to
maintain data integrity and also allows navigation
between two different instances of an entity. Every
relationship in the model needs to be supported by a
foreign key
What is the Foreign key?
 Compound key has many fields which allow you to uniquely recognize
a specific record. It is possible that each column may be not unique by
itself within the database. However, when combined with the other
column or columns the combination of composite keys become
unique.
 In this example, OrderNo and ProductID can't be a primary key as it
does not uniquely identify a record. However, a compound key of
Order ID and Product ID could be used as it uniquely identified each
record.
What is the Compound key?
 A key which has multiple attributes to uniquely
identify rows in a table is called a composite key.
The difference between compound and the
composite key is that any part of the compound
key can be a foreign key, but the composite key
may or maybe not a part of the foreign key.
 A super key uniquely identifies a row. It could be
made up of one column or many. A composite
key is a key made of more than one column. If a
Super Key is made of more than one column it is
also a composite
What is the Composite key?
 An artificial key which aims to uniquely identify each record
is called a surrogate key. These kind of key are unique
because they are created when you don't have any natural
primary key. They do not lend any meaning to the data in
the table. Surrogate key is usually an integer.
 Given example, shown shift timings of the different
employee. In this example, a surrogate key is needed to
uniquely identify each employee. E.g. start or end time
What is a Surrogate Key?
Surrogate keys are widely used and accepted
design standard in data warehouses. It is
sequentially generated unique number
attached with each and every record in
a Dimension table in any Data Warehouse. It
join between the fact and dimension
tables and is necessary to handle changes
in dimension table attributes.
-
13
Surrogate Key in DWH
Dimension tables are referenced by fact tables using keys.
When creating a dimension table in a data warehouse, a
system-generated key is used to uniquely identify a row in
the dimension. This key is also known as a surrogate key.
The surrogate key is used as the primary key in the
dimension table.
-
14
How keys of dimension tables are generated?
Fact Table Structure:
 Primary Key
 Set of Foreign Keys
 Set of Business Metrics
-
15
How key of fact table is generated?
 A Fact Table is the central table in a star
schema of a data warehouse.
 It consists of two types of columns.
 The foreign keys column allows to join with
dimension tables .
 The measure columns contain the data that
is being analyzed.
FACT TABLE
 Foreign Key – Column Type
 These are the columns as coming from
Dimension Tables
 Are the primary keys of Dimension Tables
FACT TABLE COLUMNS – FOREIGN KEY
 Fact tables - Measures
 Collection of measurements on a specific aspects
of business
 sales amount, order quantity, profit, balance and
discount amount.
Measures Or Facts
 A fact table might contain either detail level
facts or facts that have been aggregated.
 The primary purpose of Data warehouse is
reporting, and forecasting
 Many times reports are aggregations such as
sum
 Example: sales by quarter, by region,
 Many reports are usually aggregations
Additivity of Measures
 Types of Additivity of Measures
 Additive measures
 Semi-additive measures
 Non-additive measures
Types Of Additivity Of Measures
 Additive
 If a measure can be summed across all
dimensions
 The purpose of this table is to record the
sales amount for each product in each
store on a daily basis.
Date
Store
Product
Sales_Amount
Additive Measures
Semi-additive
 Sometimes, we can sum a
measure across all
dimensions except for time
 such as account balance
 We can’t sum the account balance
across the time dimension
Date
Account
Current_Balance
Semi-Additive Measures
Non-additive
 Some measures can’t ever
be summed these are called
non-additive measures
 Such as discount percentages
and prices
 Profit_Margin is a non-additive
fact, for it does not make sense to
add them up for the account level
or the day level
Date
Account
Profit_margin
Non-Additive Measures
 In the real world, it is possible to have a fact
table that contains no measures or facts.
These tables are called "Factless Fact tables".
 A factless fact table is a fact table that does
have only dimensions (keys).
 It is essentially an intersection of dimensions.
Fact less Fact Table
 The fact table would
consist of 3 dimensions:
the student dimension, the
time dimension, and the
class dimension.
Example
 Fact less Fact table does not contain any facts.
 Generally Fact less fact tables are used to record
the events such as students attendance,
attendance of participants for an Event like a
Meeting.
 There are applications in which fact tables do not
have non key data but that do have foreign keys for
the associated dimensions
Fact less Fact table
Fact less Fact table
Fact less Fact table Example
 Aggregates are pre calculated summaries derived
from the most granular fact table(level of detail in
the fact table).
 If the fact table is at the lowest grain.
 The facts or metrics are at the lowest possible level
at which they could be captured from the
operational system.
 what is the Advantages of lowest grain?
Aggregate Fact Tables
 Choose a simple STAR schema with the fact table
at the lowest possible level of granularity.
 Assume four dimension table with most granular
fact table.
 Operational system-single order, invoice, product
and so on.
 Data warehouse- produce large result set(these
retrieve hundreds and thousands
Aggregate Fact Tables
Star schema with most granular fact table
Fact base record
Fact table size
Fact table size
Need for aggregates
Aggregating fact table
One Way Aggregates
Two Way Aggregates
Three Way Aggregates

More Related Content

What's hot (20)

Errors in ms excel
Errors in ms excelErrors in ms excel
Errors in ms excel
 
Excel text function
Excel text functionExcel text function
Excel text function
 
Keys in dbms
Keys in dbmsKeys in dbms
Keys in dbms
 
Excel Chapter 2
Excel Chapter 2Excel Chapter 2
Excel Chapter 2
 
Understanding excel’s error values
Understanding excel’s error valuesUnderstanding excel’s error values
Understanding excel’s error values
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Mastering Excel Formulas and Functions
Mastering Excel Formulas and FunctionsMastering Excel Formulas and Functions
Mastering Excel Formulas and Functions
 
090225 Excel Training
090225 Excel Training090225 Excel Training
090225 Excel Training
 
Data Analytics Using MS Excel
Data Analytics Using MS ExcelData Analytics Using MS Excel
Data Analytics Using MS Excel
 
Ms Excel Basic to Advance Tutorial
Ms Excel Basic to Advance TutorialMs Excel Basic to Advance Tutorial
Ms Excel Basic to Advance Tutorial
 
Cis145 Final Review
Cis145 Final ReviewCis145 Final Review
Cis145 Final Review
 
2016 ms excel_bm
2016 ms excel_bm2016 ms excel_bm
2016 ms excel_bm
 
Excel Training
Excel TrainingExcel Training
Excel Training
 
Excel formulas with-example-narration
Excel formulas with-example-narrationExcel formulas with-example-narration
Excel formulas with-example-narration
 
MS-EXCEL Assignment Help
MS-EXCEL Assignment HelpMS-EXCEL Assignment Help
MS-EXCEL Assignment Help
 
Excel functions and formulas
Excel functions and formulasExcel functions and formulas
Excel functions and formulas
 
How to Use VLOOKUP in Excel
How to Use VLOOKUP in ExcelHow to Use VLOOKUP in Excel
How to Use VLOOKUP in Excel
 
5-A Reading
5-A Reading5-A Reading
5-A Reading
 
E-Book 25 Tips and Tricks MS Excel Functions & Formulaes
E-Book 25 Tips and Tricks MS Excel Functions & FormulaesE-Book 25 Tips and Tricks MS Excel Functions & Formulaes
E-Book 25 Tips and Tricks MS Excel Functions & Formulaes
 

Similar to Intro to Data warehousing lecture 12

Difference between fact tables and dimension tables
Difference between fact tables and dimension tablesDifference between fact tables and dimension tables
Difference between fact tables and dimension tablesKamran Haider
 
18 database features
18 database features18 database features
18 database featuresRebecca Jones
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database ModelsPrithwis Mukerjee
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database ModelsPrithwis Mukerjee
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data WarehousingAnimesh Srivastava
 
Natural vs.surrogate keys
Natural vs.surrogate keysNatural vs.surrogate keys
Natural vs.surrogate keysRon Morgan
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptxDBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptxsonudhakad173
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesJavier García Magna
 
Case study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tableCase study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tablechirag patil
 
10359485
1035948510359485
10359485kavumo
 
Intro To TSQL - Unit 4
Intro To TSQL - Unit 4Intro To TSQL - Unit 4
Intro To TSQL - Unit 4iccma
 

Similar to Intro to Data warehousing lecture 12 (20)

Difference between fact tables and dimension tables
Difference between fact tables and dimension tablesDifference between fact tables and dimension tables
Difference between fact tables and dimension tables
 
Star schema
Star schemaStar schema
Star schema
 
18 database features
18 database features18 database features
18 database features
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database Models
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database Models
 
Database Basics
Database BasicsDatabase Basics
Database Basics
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 
B & c
B & cB & c
B & c
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 
Natural vs.surrogate keys
Natural vs.surrogate keysNatural vs.surrogate keys
Natural vs.surrogate keys
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptxDBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptx
 
Dbms keys
Dbms keysDbms keys
Dbms keys
 
dotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelinesdotnetMALAGA - Sql query tuning guidelines
dotnetMALAGA - Sql query tuning guidelines
 
key.pptx
key.pptxkey.pptx
key.pptx
 
Case study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact tableCase study: Implementation of dimension table and fact table
Case study: Implementation of dimension table and fact table
 
10359485
1035948510359485
10359485
 
Intro To TSQL - Unit 4
Intro To TSQL - Unit 4Intro To TSQL - Unit 4
Intro To TSQL - Unit 4
 

More from AnwarrChaudary

Intro to Data warehousing lecture 20
Intro to Data warehousing   lecture 20Intro to Data warehousing   lecture 20
Intro to Data warehousing lecture 20AnwarrChaudary
 
Intro to Data warehousing lecture 19
Intro to Data warehousing   lecture 19Intro to Data warehousing   lecture 19
Intro to Data warehousing lecture 19AnwarrChaudary
 
Intro to Data warehousing lecture 18
Intro to Data warehousing   lecture 18Intro to Data warehousing   lecture 18
Intro to Data warehousing lecture 18AnwarrChaudary
 
Intro to Data warehousing lecture 17
Intro to Data warehousing   lecture 17Intro to Data warehousing   lecture 17
Intro to Data warehousing lecture 17AnwarrChaudary
 
Intro to Data warehousing lecture 16
Intro to Data warehousing   lecture 16Intro to Data warehousing   lecture 16
Intro to Data warehousing lecture 16AnwarrChaudary
 
Intro to Data warehousing lecture 15
Intro to Data warehousing   lecture 15Intro to Data warehousing   lecture 15
Intro to Data warehousing lecture 15AnwarrChaudary
 
Intro to Data warehousing lecture 14
Intro to Data warehousing   lecture 14Intro to Data warehousing   lecture 14
Intro to Data warehousing lecture 14AnwarrChaudary
 
Intro to Data warehousing lecture 13
Intro to Data warehousing   lecture 13Intro to Data warehousing   lecture 13
Intro to Data warehousing lecture 13AnwarrChaudary
 
Intro to Data warehousing lecture 11
Intro to Data warehousing   lecture 11Intro to Data warehousing   lecture 11
Intro to Data warehousing lecture 11AnwarrChaudary
 
Intro to Data warehousing lecture 10
Intro to Data warehousing   lecture 10Intro to Data warehousing   lecture 10
Intro to Data warehousing lecture 10AnwarrChaudary
 
Intro to Data warehousing lecture 09
Intro to Data warehousing   lecture 09Intro to Data warehousing   lecture 09
Intro to Data warehousing lecture 09AnwarrChaudary
 
Intro to Data warehousing lecture 08
Intro to Data warehousing   lecture 08Intro to Data warehousing   lecture 08
Intro to Data warehousing lecture 08AnwarrChaudary
 
Intro to Data warehousing lecture 07
Intro to Data warehousing   lecture 07Intro to Data warehousing   lecture 07
Intro to Data warehousing lecture 07AnwarrChaudary
 
Intro to Data warehousing Lecture 06
Intro to Data warehousing   Lecture 06Intro to Data warehousing   Lecture 06
Intro to Data warehousing Lecture 06AnwarrChaudary
 
Intro to Data warehousing lecture 05
Intro to Data warehousing   lecture 05Intro to Data warehousing   lecture 05
Intro to Data warehousing lecture 05AnwarrChaudary
 
Intro to Data warehousing Lecture 04
Intro to Data warehousing   Lecture 04Intro to Data warehousing   Lecture 04
Intro to Data warehousing Lecture 04AnwarrChaudary
 
Intro to Data warehousing lecture 03
Intro to Data warehousing   lecture 03Intro to Data warehousing   lecture 03
Intro to Data warehousing lecture 03AnwarrChaudary
 
Intro to Data warehousing lecture 02
Intro to Data warehousing   lecture 02Intro to Data warehousing   lecture 02
Intro to Data warehousing lecture 02AnwarrChaudary
 
Introduction to Data Warehouse
Introduction to Data WarehouseIntroduction to Data Warehouse
Introduction to Data WarehouseAnwarrChaudary
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringAnwarrChaudary
 

More from AnwarrChaudary (20)

Intro to Data warehousing lecture 20
Intro to Data warehousing   lecture 20Intro to Data warehousing   lecture 20
Intro to Data warehousing lecture 20
 
Intro to Data warehousing lecture 19
Intro to Data warehousing   lecture 19Intro to Data warehousing   lecture 19
Intro to Data warehousing lecture 19
 
Intro to Data warehousing lecture 18
Intro to Data warehousing   lecture 18Intro to Data warehousing   lecture 18
Intro to Data warehousing lecture 18
 
Intro to Data warehousing lecture 17
Intro to Data warehousing   lecture 17Intro to Data warehousing   lecture 17
Intro to Data warehousing lecture 17
 
Intro to Data warehousing lecture 16
Intro to Data warehousing   lecture 16Intro to Data warehousing   lecture 16
Intro to Data warehousing lecture 16
 
Intro to Data warehousing lecture 15
Intro to Data warehousing   lecture 15Intro to Data warehousing   lecture 15
Intro to Data warehousing lecture 15
 
Intro to Data warehousing lecture 14
Intro to Data warehousing   lecture 14Intro to Data warehousing   lecture 14
Intro to Data warehousing lecture 14
 
Intro to Data warehousing lecture 13
Intro to Data warehousing   lecture 13Intro to Data warehousing   lecture 13
Intro to Data warehousing lecture 13
 
Intro to Data warehousing lecture 11
Intro to Data warehousing   lecture 11Intro to Data warehousing   lecture 11
Intro to Data warehousing lecture 11
 
Intro to Data warehousing lecture 10
Intro to Data warehousing   lecture 10Intro to Data warehousing   lecture 10
Intro to Data warehousing lecture 10
 
Intro to Data warehousing lecture 09
Intro to Data warehousing   lecture 09Intro to Data warehousing   lecture 09
Intro to Data warehousing lecture 09
 
Intro to Data warehousing lecture 08
Intro to Data warehousing   lecture 08Intro to Data warehousing   lecture 08
Intro to Data warehousing lecture 08
 
Intro to Data warehousing lecture 07
Intro to Data warehousing   lecture 07Intro to Data warehousing   lecture 07
Intro to Data warehousing lecture 07
 
Intro to Data warehousing Lecture 06
Intro to Data warehousing   Lecture 06Intro to Data warehousing   Lecture 06
Intro to Data warehousing Lecture 06
 
Intro to Data warehousing lecture 05
Intro to Data warehousing   lecture 05Intro to Data warehousing   lecture 05
Intro to Data warehousing lecture 05
 
Intro to Data warehousing Lecture 04
Intro to Data warehousing   Lecture 04Intro to Data warehousing   Lecture 04
Intro to Data warehousing Lecture 04
 
Intro to Data warehousing lecture 03
Intro to Data warehousing   lecture 03Intro to Data warehousing   lecture 03
Intro to Data warehousing lecture 03
 
Intro to Data warehousing lecture 02
Intro to Data warehousing   lecture 02Intro to Data warehousing   lecture 02
Intro to Data warehousing lecture 02
 
Introduction to Data Warehouse
Introduction to Data WarehouseIntroduction to Data Warehouse
Introduction to Data Warehouse
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Intro to Data warehousing lecture 12

  • 1. Database keys for fact & Dimension Tables Fact Table and Fact Types Aggregate and Fact less - 1 Ch Anwar ul Hassan (Lecturer) Department of Computer Science and Software Engineering Capital University of Sciences & Technology, Islamabad Pakistan anwarchaudary@gmail.com Intro to Data warehousing
  • 2.  A DBMS key is an attribute or set of an attribute which helps you to identify a row(tuple) in a relation(table). They allow you to find the relation between two tables. Keys help you uniquely identify a row in a table by a combination of one or more columns in that table What are keys
  • 3.  Keys help you to identify any row of data in a table. In a real-world application, a table could contain thousands of records. Moreover, the records could be duplicated. Keys ensure that you can uniquely identify a table record despite these challenges.  Allows you to establish a relationship between and identify the relation between tables  Help you to enforce identity and integrity in the relationship. Why we need a Key?
  • 4.  DBMS has several types of Keys each have their different functionality:  Super Key  Primary Key  Candidate Key  Alternate Key  Foreign Key  Compound Key  Composite Key  Surrogate Key Various Keys in Database Management System
  • 5.  A superkey is a combination of columns that uniquely identifies any rows in a table. A Super key may have additional attributes that are not needed for unique identification.  A single attribute or a set of attributes that can uniquely identify all attributes of a particular relation is called Super key. On the other hands, a super key that is a proper subset of another super key is called candidate key. All candidate keys are super keys but the inverse is not true  Example, EmpSSN and EmpNum name are superkeys. What is the Super key?
  • 6.  A column or group of columns in a table which helps us to uniquely identifies every row in that table is called a primary key. This DBMS can't be a duplicate. The same value can't appear more than once in the table.  Example, StudID What is a Primary Key?
  • 7.  All the keys which are not primary key are called an alternate key. It is a candidate key which is currently not the primary key. However, A table may have single or multiple choices for the primary key.  StudID, Roll No, Email are qualified to become a primary key. But since StudID is the primary key, Roll No, Email becomes the alternative key. What is the Alternate key?
  • 8.  A super key with no repeated attribute is called candidate key.  The Primary key should be selected from the candidate keys. Every table must have at least a single candidate key  Example: In the given table Stud ID, Roll No, and email are candidate keys which help us to uniquely identify the student record in the table. What is a Candidate Key?
  • 9.  A foreign key is a column which is added to create a relationship with another table. Foreign keys help us to maintain data integrity and also allows navigation between two different instances of an entity. Every relationship in the model needs to be supported by a foreign key What is the Foreign key?
  • 10.  Compound key has many fields which allow you to uniquely recognize a specific record. It is possible that each column may be not unique by itself within the database. However, when combined with the other column or columns the combination of composite keys become unique.  In this example, OrderNo and ProductID can't be a primary key as it does not uniquely identify a record. However, a compound key of Order ID and Product ID could be used as it uniquely identified each record. What is the Compound key?
  • 11.  A key which has multiple attributes to uniquely identify rows in a table is called a composite key. The difference between compound and the composite key is that any part of the compound key can be a foreign key, but the composite key may or maybe not a part of the foreign key.  A super key uniquely identifies a row. It could be made up of one column or many. A composite key is a key made of more than one column. If a Super Key is made of more than one column it is also a composite What is the Composite key?
  • 12.  An artificial key which aims to uniquely identify each record is called a surrogate key. These kind of key are unique because they are created when you don't have any natural primary key. They do not lend any meaning to the data in the table. Surrogate key is usually an integer.  Given example, shown shift timings of the different employee. In this example, a surrogate key is needed to uniquely identify each employee. E.g. start or end time What is a Surrogate Key?
  • 13. Surrogate keys are widely used and accepted design standard in data warehouses. It is sequentially generated unique number attached with each and every record in a Dimension table in any Data Warehouse. It join between the fact and dimension tables and is necessary to handle changes in dimension table attributes. - 13 Surrogate Key in DWH
  • 14. Dimension tables are referenced by fact tables using keys. When creating a dimension table in a data warehouse, a system-generated key is used to uniquely identify a row in the dimension. This key is also known as a surrogate key. The surrogate key is used as the primary key in the dimension table. - 14 How keys of dimension tables are generated?
  • 15. Fact Table Structure:  Primary Key  Set of Foreign Keys  Set of Business Metrics - 15 How key of fact table is generated?
  • 16.  A Fact Table is the central table in a star schema of a data warehouse.  It consists of two types of columns.  The foreign keys column allows to join with dimension tables .  The measure columns contain the data that is being analyzed. FACT TABLE
  • 17.  Foreign Key – Column Type  These are the columns as coming from Dimension Tables  Are the primary keys of Dimension Tables FACT TABLE COLUMNS – FOREIGN KEY
  • 18.  Fact tables - Measures  Collection of measurements on a specific aspects of business  sales amount, order quantity, profit, balance and discount amount. Measures Or Facts
  • 19.  A fact table might contain either detail level facts or facts that have been aggregated.  The primary purpose of Data warehouse is reporting, and forecasting  Many times reports are aggregations such as sum  Example: sales by quarter, by region,  Many reports are usually aggregations Additivity of Measures
  • 20.  Types of Additivity of Measures  Additive measures  Semi-additive measures  Non-additive measures Types Of Additivity Of Measures
  • 21.  Additive  If a measure can be summed across all dimensions  The purpose of this table is to record the sales amount for each product in each store on a daily basis. Date Store Product Sales_Amount Additive Measures
  • 22. Semi-additive  Sometimes, we can sum a measure across all dimensions except for time  such as account balance  We can’t sum the account balance across the time dimension Date Account Current_Balance Semi-Additive Measures
  • 23. Non-additive  Some measures can’t ever be summed these are called non-additive measures  Such as discount percentages and prices  Profit_Margin is a non-additive fact, for it does not make sense to add them up for the account level or the day level Date Account Profit_margin Non-Additive Measures
  • 24.  In the real world, it is possible to have a fact table that contains no measures or facts. These tables are called "Factless Fact tables".  A factless fact table is a fact table that does have only dimensions (keys).  It is essentially an intersection of dimensions. Fact less Fact Table
  • 25.  The fact table would consist of 3 dimensions: the student dimension, the time dimension, and the class dimension. Example
  • 26.  Fact less Fact table does not contain any facts.  Generally Fact less fact tables are used to record the events such as students attendance, attendance of participants for an Event like a Meeting.  There are applications in which fact tables do not have non key data but that do have foreign keys for the associated dimensions Fact less Fact table
  • 27. Fact less Fact table
  • 28. Fact less Fact table Example
  • 29.  Aggregates are pre calculated summaries derived from the most granular fact table(level of detail in the fact table).  If the fact table is at the lowest grain.  The facts or metrics are at the lowest possible level at which they could be captured from the operational system.  what is the Advantages of lowest grain? Aggregate Fact Tables
  • 30.  Choose a simple STAR schema with the fact table at the lowest possible level of granularity.  Assume four dimension table with most granular fact table.  Operational system-single order, invoice, product and so on.  Data warehouse- produce large result set(these retrieve hundreds and thousands Aggregate Fact Tables
  • 31. Star schema with most granular fact table