SlideShare a Scribd company logo
1 of 19
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
Row Spanning Dependency
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
● What is Data Integrity?
– Wikipedia: “Data integrity refers to maintaining
and assuring the accuracy and consistency of
data over its entire life-cycle...”
● Consistency?
● Accuracy?
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
● Model an attribute
– Integer, not null, positive value between 1 and
2000
– Datatype and domain definition:
…, A int NOT NULL constraint ('A in (1..2000)'),
● Record inserted with value 3 in this field.
– Is it valid?
– Is it accurate?
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
● What is Data Integrity?
– Wikipedia: “Data integrity refers to maintaining
and assuring the accuracy and consistency of
data over its entire life-cycle...”
● Consistency?
● Accuracy?
● What about normalization?
– Why do we normalize?
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
create table T1(
…
int F1 NULL,
int F2 NULL,
int F3 NULL,
int F4 NULL,
int F5 NULL,
…
);
F1 F2 F3 F4 F5
<null> <null> <null> <null> <null>
F1 F2 F3 F4 F5
15 43 <null> <null> <null>
F1 F2 F3 F4 F5
15 43 9 379 403
F1 F2 F3 F4 F5
15 43 <null> 379 403
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
● What is Data Integrity?
– Assuring the data remains non-anomalous over its
entire life-cycle...
– Where “non-anomalous” means:
● the data in each field is valid when taken individually
● the data does not lead to inconsistent results when
take as meaningful groups
● Goal of Data Integrity
– Don’t let bogus data in your DB ― ever!
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Data Integrity
● Tools
– Data types/domains
– Referential
– Constraints
– Triggers
– Normalization
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Row Spanning Dependency
● Dependency between rows
● Particularly complicated
– Initial integrity
– Maintaining integrity
● No built-in tool to help
● Pretty much completely avoidable
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Row Spanning Dependency
● When two fields have a functional
dependency on each other. But the
dependency of each field is determined by
the other field contained in a different but
related row.
● That is, F1 ↔ F2, but F1 of row R1 is
dependent on the value of F2 of row R2 and
F2 of row R1 is dependent on F1 of row R3.
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Characteristics
● Generally identified by begin_value/end_value
pairs of fields.
– end_value of one row matches begin_value of the
next row: defines a series.
● DML becomes more complicated
– INSERT accompanied by UPDATE
– UPDATE accompanied by UPDATE
– DELETE accompanied by UPDATE
18 31
31 9999
1 18
begin_x end_x
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
● Model a currency conversion table
– Each currency has a conversion factor to convert
to/from USD.
– Each entry good for at least one whole day.
– Past entries must be maintained for historical
purposes.
● Each day’s conversion factor based on closing
price of previous day’s market.
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
● Based on commonly used models:
create table CurrConv(
Currency varchar( 3 ) NOT NULL (pk), -- ISO 4217 code
From_Date date NOT NULL (pk),
To_Date date NOT NULL default '12319999',
Factor double NOT NULL );
Currency From_Date To_Date Factor
‘JPY’ 1/1/2014 1/3/2014 0.006666667
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
Currency From_Date To_Date Factor
‘JPY’ 1/28/2014 12/31/9999 0.006666650
‘JPY’ 1/27/2014 1/28/2014 0.006666657
‘JPY’ 1/24/2014 1/27/2014 0.006666664
‘JPY’ 1/20/2014 1/24/2014 0.006666665
‘JPY’ 1/16/2014 1/20/2014 0.006666662
‘JPY’ 1/14/2014 1/16/2014 0.006666660
‘JPY’ 1/11/2014 1/14/2014 0.006666668
‘JPY’ 1/10/2014 1/11/2014 0.006666667
‘JPY’ 1/7/2014 1/10/2014 0.006666669
‘JPY’ 1/3/2014 1/7/2014 0.006666670
‘JPY’ 1/1/2014 1/3/2014 0.006666667
All rows for
January, 2014
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
select Factor
from CurrConv
where Currency = :Curr -- i.e. 'JPY'
and From_Date <= :AsOf -- i.e. '01/15/2014'
and To_Date > :AsOf
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
Currency From_Date To_Date Factor
‘JPY’ 1/28/2014 12/31/9999 0.006666650
‘JPY’ 1/27/2014 1/28/2014 0.006666657
‘JPY’ 1/24/2014 1/27/2014 0.006666664
‘JPY’ 1/20/2014 1/24/2014 0.006666665
‘JPY’ 1/16/2014 1/20/2014 0.006666662
‘JPY’ 1/14/2014 1/16/2014 0.006666660
‘JPY’ 1/11/2014 1/14/2014 0.006666668
‘JPY’ 1/10/2014 1/11/2014 0.006666667
‘JPY’ 1/7/2014 1/10/2014 0.006666669
‘JPY’ 1/3/2014 1/7/2014 0.006666670
‘JPY’ 1/1/2014 1/3/2014 0.006666667
All rows for
January, 2014
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
select MAX(From_Date)
from CurrConv
where Currency = :Curr
and From_Date <= :AsOf;
select Factor
from CurrConv
where Currency = :Curr -- i.e. 'JPY'
and From_Date =(
select MAX(From_Date)
from CurrConv
where Currency = :Curr
and From_Date <= :AsOf);
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Currency Conversion Table
Currency From_Date Factor
‘JPY’ 1/28/2014 0.006666650
‘JPY’ 1/27/2014 0.006666657
‘JPY’ 1/24/2014 0.006666664
‘JPY’ 1/20/2014 0.006666665
‘JPY’ 1/16/2014 0.006666662
‘JPY’ 1/14/2014 0.006666660
‘JPY’ 1/11/2014 0.006666668
‘JPY’ 1/10/2014 0.006666667
‘JPY’ 1/7/2014 0.006666669
‘JPY’ 1/3/2014 0.006666670
‘JPY’ 1/1/2014 0.006666667
All rows for
January, 2014
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Conclusion
● Data Integrity Nightmare
– Cannot guarantee non-anomalous data
– Complicated DML
– Queries perform index scans
● Easily fixed
– Just drop the offending column
– Normal DML
– Queries perform index seeks
April 5, 2014 Desert Code Camp
Row Spanning Dependency
Questions?
● TommCarr@GMail.com
● Next DDC topic:
– Implementing Bi-Temporal Access to Data
(4:45 – Rm. IRN-128)

More Related Content

Recently uploaded

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
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
 

Recently uploaded (20)

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
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?
 

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Data Integrity Row Spanning Dependency

  • 1. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity Row Spanning Dependency
  • 2. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity ● What is Data Integrity? – Wikipedia: “Data integrity refers to maintaining and assuring the accuracy and consistency of data over its entire life-cycle...” ● Consistency? ● Accuracy?
  • 3. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity ● Model an attribute – Integer, not null, positive value between 1 and 2000 – Datatype and domain definition: …, A int NOT NULL constraint ('A in (1..2000)'), ● Record inserted with value 3 in this field. – Is it valid? – Is it accurate?
  • 4. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity ● What is Data Integrity? – Wikipedia: “Data integrity refers to maintaining and assuring the accuracy and consistency of data over its entire life-cycle...” ● Consistency? ● Accuracy? ● What about normalization? – Why do we normalize?
  • 5. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity create table T1( … int F1 NULL, int F2 NULL, int F3 NULL, int F4 NULL, int F5 NULL, … ); F1 F2 F3 F4 F5 <null> <null> <null> <null> <null> F1 F2 F3 F4 F5 15 43 <null> <null> <null> F1 F2 F3 F4 F5 15 43 9 379 403 F1 F2 F3 F4 F5 15 43 <null> 379 403
  • 6. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity ● What is Data Integrity? – Assuring the data remains non-anomalous over its entire life-cycle... – Where “non-anomalous” means: ● the data in each field is valid when taken individually ● the data does not lead to inconsistent results when take as meaningful groups ● Goal of Data Integrity – Don’t let bogus data in your DB ― ever!
  • 7. April 5, 2014 Desert Code Camp Row Spanning Dependency Data Integrity ● Tools – Data types/domains – Referential – Constraints – Triggers – Normalization
  • 8. April 5, 2014 Desert Code Camp Row Spanning Dependency Row Spanning Dependency ● Dependency between rows ● Particularly complicated – Initial integrity – Maintaining integrity ● No built-in tool to help ● Pretty much completely avoidable
  • 9. April 5, 2014 Desert Code Camp Row Spanning Dependency Row Spanning Dependency ● When two fields have a functional dependency on each other. But the dependency of each field is determined by the other field contained in a different but related row. ● That is, F1 ↔ F2, but F1 of row R1 is dependent on the value of F2 of row R2 and F2 of row R1 is dependent on F1 of row R3.
  • 10. April 5, 2014 Desert Code Camp Row Spanning Dependency Characteristics ● Generally identified by begin_value/end_value pairs of fields. – end_value of one row matches begin_value of the next row: defines a series. ● DML becomes more complicated – INSERT accompanied by UPDATE – UPDATE accompanied by UPDATE – DELETE accompanied by UPDATE 18 31 31 9999 1 18 begin_x end_x
  • 11. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table ● Model a currency conversion table – Each currency has a conversion factor to convert to/from USD. – Each entry good for at least one whole day. – Past entries must be maintained for historical purposes. ● Each day’s conversion factor based on closing price of previous day’s market.
  • 12. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table ● Based on commonly used models: create table CurrConv( Currency varchar( 3 ) NOT NULL (pk), -- ISO 4217 code From_Date date NOT NULL (pk), To_Date date NOT NULL default '12319999', Factor double NOT NULL ); Currency From_Date To_Date Factor ‘JPY’ 1/1/2014 1/3/2014 0.006666667
  • 13. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table Currency From_Date To_Date Factor ‘JPY’ 1/28/2014 12/31/9999 0.006666650 ‘JPY’ 1/27/2014 1/28/2014 0.006666657 ‘JPY’ 1/24/2014 1/27/2014 0.006666664 ‘JPY’ 1/20/2014 1/24/2014 0.006666665 ‘JPY’ 1/16/2014 1/20/2014 0.006666662 ‘JPY’ 1/14/2014 1/16/2014 0.006666660 ‘JPY’ 1/11/2014 1/14/2014 0.006666668 ‘JPY’ 1/10/2014 1/11/2014 0.006666667 ‘JPY’ 1/7/2014 1/10/2014 0.006666669 ‘JPY’ 1/3/2014 1/7/2014 0.006666670 ‘JPY’ 1/1/2014 1/3/2014 0.006666667 All rows for January, 2014
  • 14. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table select Factor from CurrConv where Currency = :Curr -- i.e. 'JPY' and From_Date <= :AsOf -- i.e. '01/15/2014' and To_Date > :AsOf
  • 15. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table Currency From_Date To_Date Factor ‘JPY’ 1/28/2014 12/31/9999 0.006666650 ‘JPY’ 1/27/2014 1/28/2014 0.006666657 ‘JPY’ 1/24/2014 1/27/2014 0.006666664 ‘JPY’ 1/20/2014 1/24/2014 0.006666665 ‘JPY’ 1/16/2014 1/20/2014 0.006666662 ‘JPY’ 1/14/2014 1/16/2014 0.006666660 ‘JPY’ 1/11/2014 1/14/2014 0.006666668 ‘JPY’ 1/10/2014 1/11/2014 0.006666667 ‘JPY’ 1/7/2014 1/10/2014 0.006666669 ‘JPY’ 1/3/2014 1/7/2014 0.006666670 ‘JPY’ 1/1/2014 1/3/2014 0.006666667 All rows for January, 2014
  • 16. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table select MAX(From_Date) from CurrConv where Currency = :Curr and From_Date <= :AsOf; select Factor from CurrConv where Currency = :Curr -- i.e. 'JPY' and From_Date =( select MAX(From_Date) from CurrConv where Currency = :Curr and From_Date <= :AsOf);
  • 17. April 5, 2014 Desert Code Camp Row Spanning Dependency Currency Conversion Table Currency From_Date Factor ‘JPY’ 1/28/2014 0.006666650 ‘JPY’ 1/27/2014 0.006666657 ‘JPY’ 1/24/2014 0.006666664 ‘JPY’ 1/20/2014 0.006666665 ‘JPY’ 1/16/2014 0.006666662 ‘JPY’ 1/14/2014 0.006666660 ‘JPY’ 1/11/2014 0.006666668 ‘JPY’ 1/10/2014 0.006666667 ‘JPY’ 1/7/2014 0.006666669 ‘JPY’ 1/3/2014 0.006666670 ‘JPY’ 1/1/2014 0.006666667 All rows for January, 2014
  • 18. April 5, 2014 Desert Code Camp Row Spanning Dependency Conclusion ● Data Integrity Nightmare – Cannot guarantee non-anomalous data – Complicated DML – Queries perform index scans ● Easily fixed – Just drop the offending column – Normal DML – Queries perform index seeks
  • 19. April 5, 2014 Desert Code Camp Row Spanning Dependency Questions? ● TommCarr@GMail.com ● Next DDC topic: – Implementing Bi-Temporal Access to Data (4:45 – Rm. IRN-128)