SlideShare uma empresa Scribd logo
1 de 9
Recipes of Data Warehouse and
Business Intelligence

Staging Area: How to verify the reference day of the
data source
The Micro ETL Foundation
•

•

•

•
•

The Micro ETL Foundation is a set of ideas and solutions for Data Warehouse and
Business Intelligence Projects in Oracle environment.
It doesn’t use expensive ETL tools, but only your intelligence and ability to
think, configure, build and load data using the features and the programming
language of your RDBMS.
This recipes is another easy example based on the slides of Recipes 1 and 2 of Data
Warehouse and Business Intelligence.
Copying the content of the following slides with your editor and SQL Interface
utility, you can reproduce this example.
The solution presented here is the check of the reference day of a data source.
This is another little component to permit us to achive the complete control of the
Staging Area loading.
The problem
• In the «Recipe 3» we have seen the check about the rows number. We
have ensured this: You have received, for example, 943 rows from the data
source file. You have loaded 943 rows in the Staging Area table.
• This is not enough.
• Now we need to ensure that the reference day (DAY_KEY) of the data is
correct.
• Suppose that you start the loading of account balances file now:
wednesday at 01:00. You expect that the reference day of the balances is
yesterday, tuesday. The loading day is today, the expected day is today-1.
• If now is monday, and there is no process during week-end, the expected
day is today-3, friday
What to check
• At the end of the loading, we need to control that it is gone all ok. We
need to ensure that in this loading day, the expected day is correct. To
have this safety, we must:
1. Build a configuration table.
2. Initialize the configuration table with the expected day for every
loading day
3. Create a log table
4. Fill the log table at the end of the load of Staging Area.
• Without this check we risk to reload the same day if the source system
had some problems or it has not been able to overwrite the previous file.
The daily configuration table
•
•
•
•
•

•

•

IO_COD is the same of the configuration
table created in «Recipes2». It is unique.
DAY_KEY is the loading day.
DY_TXT is the day of the week
WD_FLG is the flag of working day.
FROM_EDAY_KEY/TO_EDAY_KEY are the
expected range of day. For daily data
source file they will have the same value.
To have a range can be useful for
monthly data files that contains all the
days of the month.
Now we see how to configure 3 years.

DROP TABLE STA_IODAY_CFT;
CREATE TABLE STA_IODAY_CFT
(
IO_COD
VARCHAR2(12),
DAY_KEY
NUMBER,
DY_TXT
VARCHAR2(3),
WD_FLG
NUMBER,
FROM_EDAY_KEY NUMBER,
TO_EDAY_KEY NUMBER
);
The load of daily table
•
•
•

The load of this table may be done only one time.
In this example we configure a daily loading (excluding week-end) from a year in
the future (sysdate+365) and 2 years in the past.
Configure holidays according to your country calendar. Here are configured only
Christmas Day, New Year's Day and Independence Day.

INSERT INTO STA_IODAY_CFT (IO_COD,DAY_KEY,DY_TXT,WD_FLG,FROM_EDAY_KEY,TO_EDAY_KEY)
WITH X AS (
SELECT TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD') AS DAY_KEY
,TO_CHAR((SYSDATE+365)-LEVEL,'dy') DY_TXT
FROM DUAL CONNECT BY LEVEL <= (365*3))
,Y AS (
SELECT TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD') AS DAY_KEY
,FIRST_VALUE(TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD'))
OVER (ORDER BY TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD')
ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS EDAY_KEY
FROM DUAL
WHERE TO_CHAR((SYSDATE+365)-LEVEL,'dy') NOT IN ('sun','sat')
AND SUBSTR(TO_CHAR(SYSDATE+365-LEVEL,'YYYYMMDD'),5)
NOT IN ('0101','0704','1225')
CONNECT BY LEVEL <= (365*3) ORDER BY 1 DESC)
SELECT 'employees1'
,X.DAY_KEY,X.DY_TXT
,(CASE WHEN (EDAY_KEY IS NULL) THEN 0 ELSE 1 END)
,Y.EDAY_KEY,Y.EDAY_KEY
FROM X
LEFT OUTER JOIN Y ON (X.DAY_KEY=Y.DAY_KEY)
ORDER BY 1,2 DESC;
The daily log table
•
•
•

•

This table must contain a row for
every data source file.
The DAY_KEY is the loading day
The others day columns are the
expected reference day and the
effective reference day.
The RET_COD contains the result
code of the check and will be ‘OK ‘ or
‘NOT OK’.

DROP TABLE STA_IODAY_LOT;
CREATE TABLE STA_IODAY_LOT
(
IO_COD
VARCHAR2(12) NOT NULL,
SOURCE_COD VARCHAR2(80) NOT NULL,
DAY_KEY
NUMBER,
FROM_EDAY_KEY NUMBER,
TO_EDAY_KEY NUMBER,
FROM_DAY_KEY NUMBER,
TO_DAY_KEY NUMBER,
RET_COD
VARCHAR2(30),
STAMP_DTS DATE
);
The load of the log table
•

•
•

We use the test case of the «Recipe 2» and the data loaded into
STA_EMPLOYEES1_STT table. (so it has an old day_key)
We calculate the min and max day_key from the Staging Area table.
We compare the received day(s) with the expected day(s)
INSERT INTO STA_IODAY_LOT (
IO_COD, SOURCE_COD, DAY_KEY,
FROM_EDAY_KEY, TO_EDAY_KEY, FROM_DAY_KEY,
TO_DAY_KEY, RET_COD, STAMP_DTS)
WITH X AS (
SELECT SOURCE_COD
,TO_CHAR(SYSDATE,'YYYYMMDD') DAY_KEY
,MIN(DAY_KEY) FROM_DAY_KEY
,MAX(DAY_KEY) TO_DAY_KEY
FROM STA_EMPLOYEES1_STT
GROUP BY SOURCE_COD)
SELECT A.IO_COD
,X.SOURCE_COD
,X.DAY_KEY
,A.FROM_EDAY_KEY,A.TO_EDAY_KEY
,X.FROM_DAY_KEY,X.TO_DAY_KEY
,(CASE WHEN (A.FROM_EDAY_KEY+A.TO_EDAY_KEY=X.FROM_DAY_KEY+X.TO_DAY_KEY) THEN 'OK' ELSE 'NOT OK' END)
,SYSDATE
FROM STA_IODAY_CFT A
LEFT OUTER JOIN X ON (A.DAY_KEY = X.DAY_KEY)
WHERE A.IO_COD = 'employees1'
AND A.DAY_KEY = TO_CHAR(SYSDATE,'YYYYMMDD');
COMMIT;
Conclusion
We are at the end of this recipe. The configuration and the log tables are:

With only two tables, we have reached the control of the reference day of the source
data without ETL tools.
This is the philosophy of Micro ETL Foundation.
Email - massimo_cenci@yahoo.it
Blog (italian/english) - http://massimocenci.blogspot.it/

Mais conteúdo relacionado

Mais procurados

Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...Massimo Cenci
 
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)Massimo Cenci
 
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...Massimo Cenci
 
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...Massimo Cenci
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 Richie Rump
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
Multiple files single target single interface
Multiple files single target single interfaceMultiple files single target single interface
Multiple files single target single interfaceDharmaraj Borse
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesAlex Zaballa
 
OER UNIT 4 PARTITION
OER UNIT 4 PARTITIONOER UNIT 4 PARTITION
OER UNIT 4 PARTITIONGirija Muscut
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionAlex Zaballa
 
Sql introduction
Sql introductionSql introduction
Sql introductionvimal_guru
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL IISankhya_Analytics
 

Mais procurados (20)

Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
Recipes 8 of Data Warehouse and Business Intelligence - Naming convention tec...
 
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)
Recipe 14 - Build a Staging Area for an Oracle Data Warehouse (2)
 
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
 
DataBase Management System Lab File
DataBase Management System Lab FileDataBase Management System Lab File
DataBase Management System Lab File
 
Dbms lab Manual
Dbms lab ManualDbms lab Manual
Dbms lab Manual
 
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...
Recipes 9 of Data Warehouse and Business Intelligence - Techniques to control...
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
Multiple files single target single interface
Multiple files single target single interfaceMultiple files single target single interface
Multiple files single target single interface
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
Sql loader good example
Sql loader good exampleSql loader good example
Sql loader good example
 
Oracle sql loader utility
Oracle sql loader utilityOracle sql loader utility
Oracle sql loader utility
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
OER UNIT 4 PARTITION
OER UNIT 4 PARTITIONOER UNIT 4 PARTITION
OER UNIT 4 PARTITION
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 

Semelhante a Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to verify the reference day

OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001jucaab
 
Microsoft SQL Server Query Tuning
Microsoft SQL Server Query TuningMicrosoft SQL Server Query Tuning
Microsoft SQL Server Query TuningMark Ginnebaugh
 
从 Oracle 合并到 my sql npr 实例分析
从 Oracle 合并到 my sql   npr 实例分析从 Oracle 合并到 my sql   npr 实例分析
从 Oracle 合并到 my sql npr 实例分析YUCHENG HU
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
 
Date dimension table - part II
Date dimension table - part IIDate dimension table - part II
Date dimension table - part IIDirk Cludts
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republicKaing Menglieng
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersJonathan Levin
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsFrederic Descamps
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsFrederic Descamps
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturesDave Stokes
 
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Citus Data
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...TAISEEREISA
 

Semelhante a Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to verify the reference day (20)

Do You Have the Time
Do You Have the TimeDo You Have the Time
Do You Have the Time
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
Microsoft SQL Server Query Tuning
Microsoft SQL Server Query TuningMicrosoft SQL Server Query Tuning
Microsoft SQL Server Query Tuning
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
从 Oracle 合并到 my sql npr 实例分析
从 Oracle 合并到 my sql   npr 实例分析从 Oracle 合并到 my sql   npr 实例分析
从 Oracle 合并到 my sql npr 实例分析
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
Date dimension table - part II
Date dimension table - part IIDate dimension table - part II
Date dimension table - part II
 
Avoiding cursors with sql server 2005 tech republic
Avoiding cursors with sql server 2005   tech republicAvoiding cursors with sql server 2005   tech republic
Avoiding cursors with sql server 2005 tech republic
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c  - New Features for Developers and DBAsOracle Database 12c  - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
cPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven FeaturescPanel now supports MySQL 8.0 - My Top Seven Features
cPanel now supports MySQL 8.0 - My Top Seven Features
 
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
Data Modeling, Normalization, and De-Normalization | PostgresOpen 2019 | Dimi...
 
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...
 

Mais de Massimo Cenci

Il controllo temporale dei data file in staging area
Il controllo temporale dei data file in staging areaIl controllo temporale dei data file in staging area
Il controllo temporale dei data file in staging areaMassimo Cenci
 
Tecniche di progettazione della staging area in un processo etl
Tecniche di progettazione della staging area in un processo etlTecniche di progettazione della staging area in un processo etl
Tecniche di progettazione della staging area in un processo etlMassimo Cenci
 
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...Massimo Cenci
 
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...Massimo Cenci
 
Note di Data Warehouse e Business Intelligence - Pensare "Agile"
Note di Data Warehouse e Business Intelligence - Pensare "Agile"Note di Data Warehouse e Business Intelligence - Pensare "Agile"
Note di Data Warehouse e Business Intelligence - Pensare "Agile"Massimo Cenci
 
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioni
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioniNote di Data Warehouse e Business Intelligence - La gestione delle descrizioni
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioniMassimo Cenci
 
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...Massimo Cenci
 
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Massimo Cenci
 
Data Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrongData Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrongMassimo Cenci
 
Letter to a programmer
Letter to a programmerLetter to a programmer
Letter to a programmerMassimo Cenci
 
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Massimo Cenci
 
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Massimo Cenci
 
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Massimo Cenci
 
Oracle All-in-One - how to send mail with attach using oracle pl/sql
Oracle All-in-One - how to send mail with attach using oracle pl/sqlOracle All-in-One - how to send mail with attach using oracle pl/sql
Oracle All-in-One - how to send mail with attach using oracle pl/sqlMassimo Cenci
 
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...Massimo Cenci
 
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisiNote di Data Warehouse e Business Intelligence - Le Dimensioni di analisi
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisiMassimo Cenci
 

Mais de Massimo Cenci (16)

Il controllo temporale dei data file in staging area
Il controllo temporale dei data file in staging areaIl controllo temporale dei data file in staging area
Il controllo temporale dei data file in staging area
 
Tecniche di progettazione della staging area in un processo etl
Tecniche di progettazione della staging area in un processo etlTecniche di progettazione della staging area in un processo etl
Tecniche di progettazione della staging area in un processo etl
 
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...
Note di Data Warehouse e Business Intelligence - Il giorno di riferimento dei...
 
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...
Recipe 12 of Data Warehouse and Business Intelligence - How to identify and c...
 
Note di Data Warehouse e Business Intelligence - Pensare "Agile"
Note di Data Warehouse e Business Intelligence - Pensare "Agile"Note di Data Warehouse e Business Intelligence - Pensare "Agile"
Note di Data Warehouse e Business Intelligence - Pensare "Agile"
 
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioni
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioniNote di Data Warehouse e Business Intelligence - La gestione delle descrizioni
Note di Data Warehouse e Business Intelligence - La gestione delle descrizioni
 
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...
Recipes 10 of Data Warehouse and Business Intelligence - The descriptions man...
 
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
 
Data Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrongData Warehouse - What you know about etl process is wrong
Data Warehouse - What you know about etl process is wrong
 
Letter to a programmer
Letter to a programmerLetter to a programmer
Letter to a programmer
 
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
Note di Data Warehouse e Business Intelligence - Tecniche di Naming Conventio...
 
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
 
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
Data Warehouse e Business Intelligence in ambiente Oracle - Il sistema di mes...
 
Oracle All-in-One - how to send mail with attach using oracle pl/sql
Oracle All-in-One - how to send mail with attach using oracle pl/sqlOracle All-in-One - how to send mail with attach using oracle pl/sql
Oracle All-in-One - how to send mail with attach using oracle pl/sql
 
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi (pa...
 
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisiNote di Data Warehouse e Business Intelligence - Le Dimensioni di analisi
Note di Data Warehouse e Business Intelligence - Le Dimensioni di analisi
 

Último

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Último (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

Data Warehouse and Business Intelligence - Recipe 4 - Staging area - how to verify the reference day

  • 1. Recipes of Data Warehouse and Business Intelligence Staging Area: How to verify the reference day of the data source
  • 2. The Micro ETL Foundation • • • • • The Micro ETL Foundation is a set of ideas and solutions for Data Warehouse and Business Intelligence Projects in Oracle environment. It doesn’t use expensive ETL tools, but only your intelligence and ability to think, configure, build and load data using the features and the programming language of your RDBMS. This recipes is another easy example based on the slides of Recipes 1 and 2 of Data Warehouse and Business Intelligence. Copying the content of the following slides with your editor and SQL Interface utility, you can reproduce this example. The solution presented here is the check of the reference day of a data source. This is another little component to permit us to achive the complete control of the Staging Area loading.
  • 3. The problem • In the «Recipe 3» we have seen the check about the rows number. We have ensured this: You have received, for example, 943 rows from the data source file. You have loaded 943 rows in the Staging Area table. • This is not enough. • Now we need to ensure that the reference day (DAY_KEY) of the data is correct. • Suppose that you start the loading of account balances file now: wednesday at 01:00. You expect that the reference day of the balances is yesterday, tuesday. The loading day is today, the expected day is today-1. • If now is monday, and there is no process during week-end, the expected day is today-3, friday
  • 4. What to check • At the end of the loading, we need to control that it is gone all ok. We need to ensure that in this loading day, the expected day is correct. To have this safety, we must: 1. Build a configuration table. 2. Initialize the configuration table with the expected day for every loading day 3. Create a log table 4. Fill the log table at the end of the load of Staging Area. • Without this check we risk to reload the same day if the source system had some problems or it has not been able to overwrite the previous file.
  • 5. The daily configuration table • • • • • • • IO_COD is the same of the configuration table created in «Recipes2». It is unique. DAY_KEY is the loading day. DY_TXT is the day of the week WD_FLG is the flag of working day. FROM_EDAY_KEY/TO_EDAY_KEY are the expected range of day. For daily data source file they will have the same value. To have a range can be useful for monthly data files that contains all the days of the month. Now we see how to configure 3 years. DROP TABLE STA_IODAY_CFT; CREATE TABLE STA_IODAY_CFT ( IO_COD VARCHAR2(12), DAY_KEY NUMBER, DY_TXT VARCHAR2(3), WD_FLG NUMBER, FROM_EDAY_KEY NUMBER, TO_EDAY_KEY NUMBER );
  • 6. The load of daily table • • • The load of this table may be done only one time. In this example we configure a daily loading (excluding week-end) from a year in the future (sysdate+365) and 2 years in the past. Configure holidays according to your country calendar. Here are configured only Christmas Day, New Year's Day and Independence Day. INSERT INTO STA_IODAY_CFT (IO_COD,DAY_KEY,DY_TXT,WD_FLG,FROM_EDAY_KEY,TO_EDAY_KEY) WITH X AS ( SELECT TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD') AS DAY_KEY ,TO_CHAR((SYSDATE+365)-LEVEL,'dy') DY_TXT FROM DUAL CONNECT BY LEVEL <= (365*3)) ,Y AS ( SELECT TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD') AS DAY_KEY ,FIRST_VALUE(TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD')) OVER (ORDER BY TO_CHAR((SYSDATE+365)-LEVEL,'YYYYMMDD') ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS EDAY_KEY FROM DUAL WHERE TO_CHAR((SYSDATE+365)-LEVEL,'dy') NOT IN ('sun','sat') AND SUBSTR(TO_CHAR(SYSDATE+365-LEVEL,'YYYYMMDD'),5) NOT IN ('0101','0704','1225') CONNECT BY LEVEL <= (365*3) ORDER BY 1 DESC) SELECT 'employees1' ,X.DAY_KEY,X.DY_TXT ,(CASE WHEN (EDAY_KEY IS NULL) THEN 0 ELSE 1 END) ,Y.EDAY_KEY,Y.EDAY_KEY FROM X LEFT OUTER JOIN Y ON (X.DAY_KEY=Y.DAY_KEY) ORDER BY 1,2 DESC;
  • 7. The daily log table • • • • This table must contain a row for every data source file. The DAY_KEY is the loading day The others day columns are the expected reference day and the effective reference day. The RET_COD contains the result code of the check and will be ‘OK ‘ or ‘NOT OK’. DROP TABLE STA_IODAY_LOT; CREATE TABLE STA_IODAY_LOT ( IO_COD VARCHAR2(12) NOT NULL, SOURCE_COD VARCHAR2(80) NOT NULL, DAY_KEY NUMBER, FROM_EDAY_KEY NUMBER, TO_EDAY_KEY NUMBER, FROM_DAY_KEY NUMBER, TO_DAY_KEY NUMBER, RET_COD VARCHAR2(30), STAMP_DTS DATE );
  • 8. The load of the log table • • • We use the test case of the «Recipe 2» and the data loaded into STA_EMPLOYEES1_STT table. (so it has an old day_key) We calculate the min and max day_key from the Staging Area table. We compare the received day(s) with the expected day(s) INSERT INTO STA_IODAY_LOT ( IO_COD, SOURCE_COD, DAY_KEY, FROM_EDAY_KEY, TO_EDAY_KEY, FROM_DAY_KEY, TO_DAY_KEY, RET_COD, STAMP_DTS) WITH X AS ( SELECT SOURCE_COD ,TO_CHAR(SYSDATE,'YYYYMMDD') DAY_KEY ,MIN(DAY_KEY) FROM_DAY_KEY ,MAX(DAY_KEY) TO_DAY_KEY FROM STA_EMPLOYEES1_STT GROUP BY SOURCE_COD) SELECT A.IO_COD ,X.SOURCE_COD ,X.DAY_KEY ,A.FROM_EDAY_KEY,A.TO_EDAY_KEY ,X.FROM_DAY_KEY,X.TO_DAY_KEY ,(CASE WHEN (A.FROM_EDAY_KEY+A.TO_EDAY_KEY=X.FROM_DAY_KEY+X.TO_DAY_KEY) THEN 'OK' ELSE 'NOT OK' END) ,SYSDATE FROM STA_IODAY_CFT A LEFT OUTER JOIN X ON (A.DAY_KEY = X.DAY_KEY) WHERE A.IO_COD = 'employees1' AND A.DAY_KEY = TO_CHAR(SYSDATE,'YYYYMMDD'); COMMIT;
  • 9. Conclusion We are at the end of this recipe. The configuration and the log tables are: With only two tables, we have reached the control of the reference day of the source data without ETL tools. This is the philosophy of Micro ETL Foundation. Email - massimo_cenci@yahoo.it Blog (italian/english) - http://massimocenci.blogspot.it/