Data Quality Rules
local graph
Chapter 6 — Data Quality Rules
Section titled “Chapter 6 — Data Quality Rules”The chapters so far have been about understanding how to shape your data quality initiative – who should be consulted, how to win their support, and how to ensure you focus on the right areas.
Having used data discovery techniques in the previous chapter to identify critical data and identify its flaws, it is now time to define data quality rules. This moves the work into a critical phase, as the rules lead to a data quality score that, ultimately, people will judge an organization’s data against.
This chapter will help you write a clearly understandable business definition of a rule, which can then be converted into a programmatic check of data with a data quality tool. We will explore all the different features of a rule, such as rule thresholds, how they are assigned to data quality dimensions, assigning a monetary value to a rule failure, and weighting important rules over others.
In this chapter, we will cover the following topics:
- An introduction to data quality rules
- The key features of data quality rules
- Implementation of data quality rules
An introduction to data quality rules
Section titled “An introduction to data quality rules”A data quality rule is logic that is applied to each row of a dataset, which can determine whether the row of data is correct or incorrect. Correct data is deemed to have passed the rule, and incorrect data is deemed to have failed the rule – hence, the term failed data, which is used heavily in Chapter 7.
Data quality rules always give a Boolean output – in other words, a row of data always passes or fails.
The following table provides a few (purposefully very simple) examples:
| Business logic | Passed row example | Failed row example |
|---|---|---|
| The VAT number must be complete for all suppliers. | Any row with any character in this field would pass. | Any row which is “null” or “blank” would fail. |
| The VAT number must be in the format AA111111111, where A = a non-numerical character and 1 = a numerical character. | GB123456789 | 12GB3456789 |
| Suppliers in the “Services” category (Supplier Group 1-1) must have a payment term of 30 days or more. | 60 days | Pay immediately |
Table 6.1 – Examples of data quality rules
The power of these rules is not in each one individually; it is in the amalgamation of the individual results of each rule into a broad picture of the data quality position, and also in the provision of a clear list of failed records that can be corrected.
The simple examples in Table 6.1 provide an understanding of the concept of a rule, but they lack one critical element – a rule scope.
Rule scope
Section titled “Rule scope”Rules often lack impact when they are as generic as the first two examples in Table 6.1. What usually increases the impact of a rule is to make it specific – in other words, defining a scope for the rule. The final rule in Table 6.1 already does this. The scope of the rule is specific to the “Services” category of suppliers. This means that other types of suppliers, such as government, intercompany entities (companies that are part of the same group), and utilities will not be subject to this rule. That might be appropriate because perhaps these suppliers need to be paid immediately. If the rule has been applied generically to all these suppliers, then many “false positives” would be generated, which would reduce trust in the rule from end users.
A rule scope also needs to be applied to the other rules in the preceding table, as shown in Table 6.2:
| Amended rule definition | Rule scope | Importance of the scope |
|---|---|---|
| The VAT number must be complete for UK and European Union (EU) suppliers with a turnover greater than the minimum requirement for each country (for example, £80,000 in the UK). | The suppliers table will include a field to capture supplier total turnover and a field for the region of the supplier. All suppliers with a region equal to the EU and turnover in excess of the minimum for VAT registration in each country will be included in the rule scope. For example, all UK companies will be included if their turnover is greater than £80,000. | VAT is a UK and European concept primarily, and therefore, suppliers from outside these regions are not expected to have a VAT number (there are some exceptions to this, but I will ignore these to keep this example simple). If “micro” suppliers (suppliers with a very small turnover) were included, they would be asked for a VAT number, and many would not have one. |
| Suppliers in the UK must have a VAT number in the format AA111111111, where A = a non-numerical character and 1 = a numerical character. | This rule applies to only UK suppliers. The format in other European countries is different. In reality, there would be many subtly different sub-rules that would be grouped together into an “invalid VAT numbers” rule. The complexity of EU VAT number formats is shown in this article from the UK government: https://www.gov.uk/guidance/vat-eu-country-codes-vat-numbers-and-vat-in-other-languages. | If the rule provided in Table 6.1 was not made specific to the UK suppliers, it would identify all suppliers from outside the UK as failed data because their VAT number formats differ. |
Table 6.2 – Amended rules with an appropriate scope applied
When asking business users for data quality rules in design workshops, often they will provide rules like those listed in Table 6.1, without a clearly defined scope. It is important to challenge these and see whether there is some missing scope information. Final rules usually read more like those listed in Table 6.2.
If you are unable to get this level of detail from your stakeholders, the rule will be built without the appropriate scope and will identify false positives. These false positives will help to identify where a rule scope needs to be more tailored. This, in turn, will allow you to iterate the rule to a new version that only returns truly incorrect data. Clearly, it is more efficient to identify the correct scope from the beginning, but in reality, some iteration always happens.
The differences in scope between rules lead to different numbers of records being assessed. Consider a case where an organization has 3,000 employees and writes data quality rules to assess the quality of the employee master data. Some of the rules may apply to all 3,000 employees, but some may apply only to a subset of these records, as shown in the following table: