Mapping Data with Metadata Knowledge Graphs
local graph
Chapter 8 — Mapping Data with Metadata Knowledge Graphs
Section titled “Chapter 8 — Mapping Data with Metadata Knowledge Graphs”Modern enterprises are extremely rich in data. But that data is distributed across silos, heterogeneous, and often of variable quality.
Being able to understand where your data resides, how it’s processed, and who consumes it is an important part of running an enterprise. It’s a key component of data governance and increasingly important for self-serve data consumers.
A metadata knowledge graph is an enterprise-wide map which records the shape and location of data, the systems which process that data, and its consumers. Importantly, a metadata knowledge graph links data, processes, and consumers so that the provenance of data is explicit and easy to reason about (e.g., for compliance and regulatory demands).
In this chapter, you’ll learn about the challenges of stewarding data in the modern enterprise and how a metadata knowledge graph can help. You’ll see how the modern distributed data landscape can be (logically) reunified by a metadata knowledge graph and how complex systems architectures can be tamed with the same technique. This is reinforced by an end-to-end example designed to resemble a typical enterprise. But first, the challenge of data stewardship must be addressed.
The Challenge of Distributed Data Stewardship
Section titled “The Challenge of Distributed Data Stewardship”As organizations evolve, different departments implement applications and processes to solve their needs. Individual departments may store some of the same information, so it is not uncommon for duplicate or (worse still) nearly duplicate data to reside in silos.
Often these systems are implemented without consideration of the overall knowledge-organization needs of the business since that isn’t owned by any individual department (and may not have an explicit owner at all). With data in a patchwork state, it’s hard to understand a customer’s journey or the success factors for a space mission.
Metadata (data that describes data) is a critical element in modern information systems management. A metadata map provides a lens over an organization’s entire data ecosystem, allowing you to manage data across the enterprise. As such, metadata knowledge graphs are a very useful foundational layer in your information architecture.
High-quality metadata ensures that users can navigate vast, heterogeneous data assets whose quality and freshness are variable. It helps data analysts, data scientists, and ML engineers access the right data quickly. And it can explain the state of data assets for auditing and regulatory purposes.
But managing metadata has been and is a significant challenge. To address this challenge, some of the largest organizations are converging their data into metadata hubs backed by a knowledge graph.
Metadata Hubs
The trend for metadata hubs backed by knowledge graphs started in 2017 when Airbnb announced its Dataportal platform at their “Democratizing Data at Airbnb” (https://oreil.ly/LecTk) talk at GraphConnect Europe 2017. This was followed by Lyft with Amundsen (https://oreil.ly/qSNta), the data discovery metadata engine, and LinkedIn with Datahub (https://oreil.ly/88YWU). Commercial solutions combining knowledge graphs for metadata management have since followed.
It is not only large organizations that benefit from knowledge graphs for metadata. With the support of frameworks like those in “Metadata Hubs”, metadata knowledge graphs can be very helpful for building higher-order knowledge graph systems, for data science, and for compliance and regulatory purposes. The kind of entities captured in metadata knowledge graphs are the common data assets found in a modern data stack and typically include datasets, tasks and pipelines, and data sinks. The following sections serve as guidelines for building your own metadata knowledge graph.
Datasets Connected to Data Platforms
Section titled “Datasets Connected to Data Platforms”Tables, documents, streams—any data collection is a dataset. Datasets are connected to a system that processes or stores them. They can be broken down into a collection of data field descriptions that describe the public schema of the dataset.
Figure 8-1 shows the subgraph representing a table with customer information stored in Google BigQuery. The Dataset node is connected to the DataPlatform node through the source relationship. It has three Field nodes.
Figure 8-1. Metadata model datasets and data platforms
As you incorporate metadata like that in Figure 8-1, you begin to create a map of your data as it exists in systems. From there, it is possible to link logically common records across systems as well as to show how inputs from one system become outputs to another via tasks and pipelines.
Tasks and Data Pipelines
Section titled “Tasks and Data Pipelines”A task is any data job that processes a data asset. A simple example is an ETL task that, for example, standardizes the values of the country field in a CSV file. Tasks can be grouped in chains that form data pipelines or data flows. The chain determines the order in which tasks are executed and therefore makes the dependencies between tasks explicit, as in Figure 8-2.
Figure 8-2. Tasks and data pipelines
Figure 8-2 shows how output data from a system becomes input to another. It can be used to understand which systems and users touch the data (e.g., for compliance and regulatory reasons) as well as to aid understanding of the provenance of the data. Once the start and end points for the pipeline are understood, they can be fed back as shortcut links into the data set part of the metadata graph from Figure 8-1.
Data Sinks
Section titled “Data Sinks”A data sink is any kind of terminal data consumer task, from a data visualization in a business intelligence tool to an ML training dataset. Data sinks are connected to datasets, but unlike the tasks described earlier, they don’t produce new datasets. All elements in the metadata graph can be linked to data domains, have owners, and be connected to catalog terms representing related business terms from an enterprise ontology, glossary, or standard terminology in use, with descriptions or documentation attached to them.
Mapping data sinks to data allows you to understand which users and systems consume the data. It helps with planning for systems migrations and shows which data and pipelines are valued (and which aren’t).
Metadata Graph Example
Section titled “Metadata Graph Example”An example describing a data pipeline for standardizing and aggregating sales data by month is shown in Figure 8-3. Three datasets represent sales data in CSV format: the raw dataset (sales_details_raw) extracted from an operational system, the dataset after the standardization of some reference fields (sales_details_std), and the dataset aggregated by month (sales_monthly_agg).
Figure 8-3. An expanded metadata graph showing lineage, domains, and ownership
Once your metadata graph is populated with datasets, tasks, and data sinks, you can run queries to understand your data ecosystem. For example, Example 8-1 shows a query to find all datasets that are described by a specific catalog term (e.g., location_info) and count how many data sinks consume them.
Example 8-1. Querying datasets by catalog term and usage
MATCH (d:Dataset)-[:described_by]->(:CatalogTerm {name:'location_info'})RETURN d.id AS dataset_id, d.desc AS dataset_desc, d.type AS dataset_type, count{ (d)<-[:consumes]-(:DataSink) } AS dataset_usage_countSimilarly, you can explore the metadata graph to assess the impact of a failing task. In Example 8-2 you can see a query that returns the list of data consumers (data sinks) and their owners who would be affected by a given task failing.1
Example 8-2. Query that returns a list of data sinks and their owners
MATCH (t:Task)-[:produces|consumes*2..]->(:Dataset)<-[:consumes]-(s:DataSink)-[:owned_by]->(o)WHERE t.name = 'standardise_reference_fields'RETURN s.id AS affectedDataConsumerID, s.type AS affectedDataConsumerType, s.desc AS affectedDataConsumerDesc, o.id AS ownerID, o.name AS ownerNameAnother common type of analysis that uses a metadata knowledge graph is data lineage. This use case is the inverse of the previous one from a graph point of view. The simplest data lineage question could be “Which data platforms are the sources of the data for Dashboard X?” The answer comes from the Cypher query in Example 8-3.
Example 8-3. A simple data lineage query
MATCH (s:DataSink)-[:consumes]->(:Dataset)-[:produces|consumes*2..]-(raw:Dataset)-[:source]->(dp:DataPlatform)WHERE s.type = 'Dashboard' AND s.id = 'X'RETURN raw.id AS sourceDatasetID, raw.type AS sourceDatasetType, dp.id AS sourcePlatformID, dp.type AS sourcePlatformTypeThere are many more questions related to metadata management that you could ask such a rich dataset. You can even analyze the graph using graph algorithms, like in Chapter 6, to surface strong connections (or disconnections) between teams and data domains because a map of how data flows in an organization (and that is exactly what this knowledge graph is) is a proxy for the operations of a company.
Using Relationships to Connect Data and Metadata
Section titled “Using Relationships to Connect Data and Metadata”In a graph, you define relationships to describe how entities interrelate. For example, it is possible for a graph to state that a customer subscribes to a service by linking the customer node and the service node through a SUBSCRIBES_TO relationship. But relationships can also be used to connect data and metadata in the same graph.
Figure 8-4 shows a graph with two layers. The bottom layer shows the data pertaining to customers and the services to which they subscribe. The top layer has some metadata that describes the provenance of the customer and subscription data. This metadata shows how customer information is part of a dataset sourced from an external system, which is curated by a particular data steward.
Figure 8-4. Relationships connect the data and metadata layers
Using a knowledge graph like the one in Figure 8-4, you can answer domain questions like “Which customers subscribe to service X?” You can also provide confidence in the answer by supplying provenance and governance metadata. Importantly, data architects can implement this technique in a noninvasive manner with respect to the source systems containing customer data, by building it as a layer above those systems.
A globally linked view of data unlocks many significant use cases. Figure 8-4 shows the powerful combination of the data and metadata planes in the graph, but it’s easy to see how to construct a complete view of a customer by linking disparate partial views of customers across different systems. You could enrich the original customer view with the customer’s behavior over their lifetime, detect patterns for good and bad customers, and adapt processes to suit their behavior.
At the metadata level, you can start with a catalog of well-described datasets connected to the data sources where they are hosted. But you can also use the techniques in the rest of this chapter to enrich them by linking them to vocabularies, taxonomies, and ontologies to enable interoperability. Or you can add ownership or stewardship information to enhance data governance and map where data came from as well as which systems and individuals have handled it. A unified, deduplicated view of data enabled by a metadata graph is a solid foundation for several use cases, including semantic search.
Summary
Section titled “Summary”This chapter has discussed the notion of metadata graphs as a foundational layer to track enterprise data assets, processes, and consumers. By integrating relevant data and metadata in a knowledge graph and defining the relationships within the data itself, you have seen how to push intelligence into the data. With metadata knowledge graphs, you’ve seen how to create knowledge graphs that allow consumers to search enterprise data for terms that don’t even explicitly exist in text!
Given a metadata knowledge graph, you can discover, reason about, and steward data assets across the enterprise. While this is useful on its own, it can also serve as the basis for higher-level use cases. In the next chapter, you’ll encounter some of those use cases as you look for fraudsters, anomalies, and skills and create recommendations.
Footnotes
Section titled “Footnotes”-
Chapter 11 gives more detail on impact analysis. ↩