Data Integrity Testing: 7 Examples From Simple To Advanced (2024)

You know those little disclaimers you always see about past performance not being indicative of future results?

Well, the same goes for your data. Just because it looked good yesterday doesn’t mean it’ll hold up tomorrow – and that’s why we’re talking about data integrity testing today.

Data integrity testing is the process of ensuring data is fit for the task at hand and available to only those who should have access.

Some examples include validating that values are in the right format, checking for duplicate records, making sure relationships between tables still make sense, and comparing current data to source systems.

Checks in SQL can help, so we’re sharing 7 examples, from simple to advanced, to get started on your data integrity testing. Plus, we share next steps for how data observability tools can help your team maintain and automate data integrity in larger, more complex data stacks.

Table of Contents

Simple data integrity testing examples

Let’s assume you have a table called [Orders] which stores order information:

CREATE TABLE Orders ( OrderID INT PRIMARY KEY, ProductID INT NOT NULL, Quantity INT NOT NULL, OrderDate DATE NOT NULL);

Now, let’s look at a few simple data integrity tests you could do.

Check for missing values

You want to ensure that there are no missing values in the [ProductID, Quantity,] and [OrderDate] columns:

SELECT * FROM OrdersWHERE ProductID IS NULL OR Quantity IS NULL OR OrderDate IS NULL;

This SQL query will return any rows where any of those columns contain missing values. If the query returns no rows, then the data integrity testing constraint on those columns is satisfied.

Check for duplicate orders

Each [OrderID] should be unique:

SELECT OrderID, COUNT(*) as DuplicateCount FROM OrdersGROUP BY OrderIDHAVING COUNT(*) > 1;

If this query returns any rows, it indicates there are duplicate [OrderID]s in the table.

Check for negative quantities

An order quantity should not be negative:

SELECT * FROM OrdersWHERE Quantity < 0;

If this query returns any rows, it indicates there are orders with negative quantities.

Check for future orders

Let’s say you don’t accept orders with future dates:

SELECT * FROM OrdersWHERE OrderDate > CURRENT_DATE;

If this query returns any rows, it indicates there are orders with dates in the future.

These are just simple examples. In real-world scenarios, data integrity tests can get quite complex depending on the business rules and data model.

More advanced data integrity testing examples

Now, let’s take a hypothetical scenario of a retail eCommerce platform with two related tables: [Customers] and [Orders].

CREATE TABLE Customers ( CustomerID INT PRIMARY KEY, Email VARCHAR(255) NOT NULL, SignupDate DATE NOT NULL);CREATE TABLE Orders ( OrderID INT PRIMARY KEY, CustomerID INT, ProductID INT NOT NULL, Quantity INT NOT NULL, OrderDate DATE NOT NULL, FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID));

Here’s a more advanced integrity check:

Referential integrity

You want to ensure that every order has a valid customer associated with it.

SELECT * FROM OrdersWHERE CustomerID IS NOT NULL AND CustomerID NOT IN (SELECT CustomerID FROM Customers);

This would fetch orders that have a CustomerID not found in the Customers table, potentially highlighting orphaned records.

Check for duplicate emails

Each customer’s email should be unique:

SELECT Email, COUNT(*) as DuplicateCount FROM CustomersGROUP BY EmailHAVING COUNT(*) > 1;

Temporal integrity

Customers shouldn’t have orders before they actually signed up:

SELECT o.OrderID, o.CustomerID, o.OrderDate, c.SignupDateFROM Orders oJOIN Customers c ON o.CustomerID = c.CustomerIDWHERE o.OrderDate < c.SignupDate;

While these SQL queries are great at getting a quick look at the integrity of your data, you can’t create a data integrity test for every way data can break, and if you could, it would be impossible to consistently scale across all of your pipelines.

How to automate data integrity testing

Managing and maintaining data integrity, especially in larger and more complex data stacks, can be a challenging task when done manually.

That’s why data observability solutions like Monte Carlo are essential. By using machine learning to automatically monitor for broken data pipelines and data anomalies, data engineering teams can resolve these issues rapidly and prevent data downtime.

For instance, Monte Carlo automatically deploys across your most critical data pipelines, catching freshness, volume, and schema issues out-of-the-box, like stale fields that impact the integrity of an executive dashboard or breaking schema changes accidentally pushed by upstream software engineers.

These issues (and many others!) can be easily and scalably caught with ML-enabled data observability solutions. Additionally, data observability solutions like Monte Carlo provide the necessary triaging and resolution tools to quickly resolve issues before they wreak havoc on downstream consumers.

Interested in how data observability can improve your data integrity? Schedule time to talk to us in the form below!

Our promise: we will show you the product.

Data Integrity Testing: 7 Examples From Simple To Advanced (2024)

FAQs

What is an example of data integrity testing? ›

Some examples include validating that values are in the right format, checking for duplicate records, making sure relationships between tables still make sense, and comparing current data to source systems.

What is data integrity with an example? ›

Data integrity is a concept and process that ensures the accuracy, completeness, consistency, and validity of an organization's data. By following the process, organizations not only ensure the integrity of the data but guarantee they have accurate and correct data in their database.

What are the 5 principles of data integrity? ›

The term ALCOA is an acronym entailing the various principles as defined by the FDA. It stands for Attributable, Legible, Contemporaneous, Original, and Accurate.

What is an integrity test example? ›

Examples of Overt Integrity Questions:

Do you believe that taking paper or pens without permission from your work place is stealing? Do you believe most employers take advantage of the people who work for them?

What is data integrity real time examples? ›

An example that illustrates data integrity's importance is when banks use Know Your Customer (KYC) protocols to authenticate customer identities and prevent illicit activities like money laundering.

What is a data integrity checklist? ›

Data Integrity Check refers to the process of verifying and maintaining the quality and consistency of data stored in a database or data lakehouse. It involves various techniques and mechanisms to identify and correct any potential errors, inconsistencies, or anomalies in the data.

What is data integrity in QA? ›

It encompasses the technologies, policies and practices deployed to safeguard data across its lifecycle, ensuring that only authorized personnel can access sensitive information to maintain confidentiality and trust. Data integrity is the overarching principle that includes data quality and security elements.

How can we demonstrate data integrity? ›

How to ensure data integrity compliance
  1. Employee training. Organizations typically create policies and procedures designed to govern the collection, access and protection of business-related data. ...
  2. Establish an integrity culture. ...
  3. Validate the data. ...
  4. Process data sensibly. ...
  5. Protect data. ...
  6. Implement strong security.

What are the 7 principles of data integrity? ›

Lawfulness, fairness, and transparency; ▪ Purpose limitation; ▪ Data minimisation; ▪ Accuracy; ▪ Storage limitation; ▪ Integrity and confidentiality; and ▪ Accountability. These principles are found right at the outset of the GDPR, and inform and permeate all other provisions of that legislation.

What are the 7 principles of data security? ›

If your company handles personal data, it's important to understand and comply with the 7 principles of the GDPR. The principles are: Lawfulness, Fairness, and Transparency; Purpose Limitation; Data Minimisation; Accuracy; Storage Limitations; Integrity and Confidentiality; and Accountability.

What are the 5 pillars of data integrity? ›

5 Fundamentals of Data Integrity
  • Data accuracy: Ensure that data is accurate and reflects the true state of the information it represents. ...
  • Data consistency: Ensure that data remains consistent across different databases, systems, and applications. ...
  • Reliability: ...
  • Integrity Controls: ...
  • Auditing and Monitoring:
Jan 3, 2024

What is an example of data quality integrity? ›

Data integrity affects relationships. For example, a customer profile includes the customer name and one or more customer addresses. In case one customer address loses its integrity at some stage in the data journey, the related customer profile can become incomplete and invalid.

What are the two main types of integrity tests? ›

Types of integrity screening
Covert integrity testingOvert integrity testing
Used to gauge whether an individual is trustworthy, dependable, and honestUsed to determine if an individual behaves in a trustworthy, dependable, and honest way
More likely to produce truthful responsesLess likely to produce truthful responses
2 more rows
Mar 15, 2022

Which of the following are examples of data integrity issues? ›

Here are seven examples of data integrity issues and how to address them, so they don't impact operations and your bottom line.
  • Lack of data integration. ...
  • Manual data entry and collection processes. ...
  • Multiple analytics tools. ...
  • Poor auditing. ...
  • Reliance on legacy systems. ...
  • Improper data entry training.

What are the four types of data integrity? ›

Additionally, data integrity can be applied to database management as well through one of four categories: entity integrity, referential integrity, domain integrity and user-defined integrity.

Top Articles
8 Financial Ratio Analysis that Every Stock Investor Should Know!
Average Directional Index (ADX): Definition and Formula
WALB Locker Room Report Week 5 2024
Cappacuolo Pronunciation
Somboun Asian Market
Gomoviesmalayalam
Western Union Mexico Rate
Pickswise the Free Sports Handicapping Service 2023
Knaben Pirate Download
Ukraine-Russia war: Latest updates
Assets | HIVO Support
Reddit Wisconsin Badgers Leaked
Summoner Class Calamity Guide
Sky X App » downloaden & Vorteile entdecken | Sky X
Abortion Bans Have Delayed Emergency Medical Care. In Georgia, Experts Say This Mother’s Death Was Preventable.
Pretend Newlyweds Nikubou Maranoshin
Mission Impossible 7 Showtimes Near Marcus Parkwood Cinema
Schedule 360 Albertsons
Skip The Games Fairbanks Alaska
Holiday Gift Bearer In Egypt
Directions To Cvs Pharmacy
Ecampus Scps Login
8000 Cranberry Springs Drive Suite 2M600
Chime Ssi Payment 2023
Trivago Myrtle Beach Hotels
Jesus Revolution Showtimes Near Regal Stonecrest
Acurafinancialservices Com Home Page
Pensacola Tattoo Studio 2 Reviews
Frank Vascellaro
Vip Lounge Odu
Rogold Extension
Salons Open Near Me Today
Pch Sunken Treasures
Moses Lake Rv Show
Powerball lottery winning numbers for Saturday, September 7. $112 million jackpot
Justin Mckenzie Phillip Bryant
Movies123.Pick
Space Marine 2 Error Code 4: Connection Lost [Solved]
Culvers Lyons Flavor Of The Day
Best Restaurants Minocqua
Immobiliare di Felice| Appartamento | Appartamento in vendita Porto San
Tfn Powerschool
Craigslist/Nashville
Yale College Confidential 2027
Senior Houses For Sale Near Me
Marine Forecast Sandy Hook To Manasquan Inlet
Edict Of Force Poe
Leslie's Pool Supply Redding California
Latest Posts
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 6100

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.