A knowledge graph is a structure that connects diverse pieces of information, helping you uncover relationships and insights that might not be immediately apparent. In some cases, you need to bridge two types of data together: structured and unstructured data.

In this article, we provide a clear, accessible guide to building your first knowledge graph. We’ll show you how to connect structured and unstructured data, offering a new lens through which to view and analyze your information.

Understanding Structured and Unstructured Data with Knowledge Graphs

To effectively build a knowledge graph that serves as a bridge between different data types, it’s crucial to first understand the distinct characteristics of structured and unstructured data.

What is Structured Data?

Structured data is highly organized and easily searchable due to its fixed schema. This type of data is typically stored in relational databases or spreadsheets, where each piece of information is stored in a predefined model or format.

Examples of structured data include customer names in a CRM system, sales figures in a spreadsheet, or transaction histories in a database. The predictability of structured data makes it straightforward to collect, query, and analyze, providing a solid foundation for any data-driven operation.

What is Unstructured Data

Unstructured data lacks a predefined format or structure, making it more challenging to collect, process, and analyze. This type of data encompasses a wide range of formats, including text files, emails, social media posts, videos, images, and more.

The richness and diversity of unstructured data offer a wealth of potential insights, but extracting these insights requires sophisticated processing techniques, such as natural language processing (NLP) or image recognition.

The Challenge of Linking Structured and Unstructured Data

The primary challenge in linking structured and unstructured data lies in their inherent differences. Structured data’s predictability contrasts sharply with the free-form nature of unstructured data. Bridging this gap requires innovative approaches that can interpret and connect the underlying information within unstructured data to the clear, organized format of structured data.

The Benefits of Integration

Integrating structured and unstructured data offers numerous benefits. It provides a more comprehensive view of the information, enabling deeper insights and more informed decision-making.

For instance, combining customer transaction data (structured) with customer feedback on social media (unstructured) can offer a more holistic view of customer satisfaction and behavior. Such integration enhances data analysis, predictive modeling, and business intelligence.

Midjourney depiction of knowledge graphs

Introduction to Knowledge Graphs for Linking Structured and Unstructured Data

Knowledge graphs are an indispensable tool in data science, especially for linking structured and unstructured data.

Knowledge graph diagram

What is a Knowledge Graph?

Unlike traditional databases that store data in rows and columns, knowledge graphs depict data in a graph format, where entities are nodes, and the relationships between them are edges. This structure allows for a more intuitive and flexible representation of complex relationships and interdependencies.

Components of a Knowledge Graph

  • Nodes: These are the primary entities or objects in a knowledge graph, representing data points such as people, places, products, or concepts.
  • Edges: Edges connect nodes, representing the relationships or interactions between them. These relationships can be varied and multidimensional, reflecting the complexity of real-world data.
  • Properties: Both nodes and edges can have properties, providing additional details or attributes about them. For example, a node representing a person could have properties like name, age, and occupation.

Knowledge Graphs vs. Traditional Databases

While traditional databases excel in handling structured data with a fixed schema, they often fall short when it comes to managing complex, interconnected, and heterogeneous data.

Knowledge graphs, on the other hand, are inherently designed to accommodate such complexity, offering a more dynamic and interconnected data model.

This makes knowledge graphs particularly well-suited for scenarios where relationships and connections between data points are as crucial as the data points themselves.

Advantages of Knowledge Graphs for Linking Structured and Unstructured Data

  • Flexible schema: Adaptable to evolving data models and relationships.
  • Efficient querying: Handles complex queries involving multiple levels of relationships.
  • Semantic richness: Captures meaning and context through ontologies and vocabularies.
  • Inference and reasoning: Discovers new, implicit knowledge based on semantic rules.
  • Scalability: Distributes the graph across machines for efficient storage and processing.
  • Data integration: Provides a unified view of data from diverse sources.
  • Knowledge discovery: Facilitates intuitive exploration and uncovering of insights.
  • NLP compatibility: Integrates with text mining and understanding techniques.
  • Explainable AI: Provides a transparent foundation for explainable AI systems.
  • Domain-specific representation: Tailors to specific fields or industries.

Linking Structured and Unstructured Data with Knowledge Graphs

Knowledge graphs excel in integrating structured and unstructured data because they can represent entities and relationships in a format that mirrors human understanding and cognition.

For instance, a knowledge graph can connect a structured database of customer information with unstructured data like customer reviews or social media posts, providing a 360-degree view of the customer experience. This integration creates more comprehensive analyses and insights.

Visualizing Knowledge Graphs

Visualization is a powerful feature of knowledge graphs, providing a clear representation of complex relationships. Users can visually navigate through the connections, explore the network of relationships, and gain insights that would be challenging to obtain from traditional data representations.

Midjourney depiction of preparing data for knowledge graph

Preparing Your Data

Before you can construct a knowledge graph that links structured and unstructured data, it’s essential to prepare your data. This preparation involves collecting, organizing, cleaning, and transforming your data. Here’s how to lay the groundwork for a successful knowledge graph construction.

Step 1: Collecting Structured Data

Determine where your structured data resides. It could be in relational databases, spreadsheets, or cloud storage. Select only the data that is relevant to the relationships and insights you aim to derive. Finally, make sure that the data is consistent in terms of format and units. For instance, dates should be in a uniform format across your datasets.

Step 2: Preparing Unstructured Data

Identify sources of unstructured data, such as text documents, emails, social media posts, or images. For textual data, use natural language processing (NLP) techniques to extract meaningful information. Convert text to a consistent format, handling variations in language or style. For images or videos, use appropriate techniques like image recognition or video analysis to extract relevant features or metadata.

Step 3: Data Cleaning and Normalization

Eliminate errors, duplicates, and irrelevant data points to ensure the quality of your data. Next, standardize data formats and values. For example, convert all text to lowercase or standardize date formats. If you have missing data, decide how to deal with missing values, whether it’s by imputation, removal, or leaving them as is, based on their impact on your knowledge graph.

Step 4: Transforming Unstructured Data into Structured Information

Use NLP to identify entities and their attributes within unstructured text. Entities can become nodes in your knowledge graph. Then, identify relationships between entities within unstructured data. These relationships will form the edges in your knowledge graph. Finally, leverage metadata from unstructured data (like timestamps or geolocation from images) as structured data points in your knowledge graph.

Step 5: Ensuring Interoperability

Establish a schema that allows for the integration of both structured and unstructured data into the knowledge graph. Create identifiers or keys that can link data points across different datasets or data types, ensuring they can be connected within the knowledge graph.

Building Your First Knowledge Graph

With your data prepared and primed, it’s time to construct the knowledge graph. This process involves creating nodes and edges that represent your data entities and their relationships. Here’s a step-by-step guide to building your first knowledge graph, linking structured and unstructured data.

Step 1: Define Your Nodes

  • Identify Entities: Determine the primary entities in your data. These could be customers, products, locations, or any other significant objects or concepts represented in your data.
  • Create Nodes for Structured Data: For each entity in your structured data, create a node in the knowledge graph. Ensure each node has a unique identifier.
  • Incorporate Unstructured Data as Nodes: Transform key entities extracted from unstructured data into nodes. For example, entities identified through NLP in text data can become additional nodes in the graph.

Step 2: Establish Relationships (Edges)

  • Identify Relationships in Structured Data: Define the relationships existing within your structured data. For example, a customer “purchases” a product or a person “lives in” a location.
  • Extract Relationships from Unstructured Data: Use NLP or other analysis techniques to identify relationships in unstructured data. For instance, text analysis might reveal that a person “mentions” a product in a review.
  • Create Edges: For each identified relationship, create an edge in the knowledge graph, linking the corresponding nodes.

Step 3: Add Properties and Attributes

  • Define Properties for Nodes: Assign relevant attributes to each node. For example, a customer node might include properties like age, gender, and purchase history.
  • Assign Properties to Edges: Edges can also have properties that describe the nature or strength of the relationship, such as the frequency or context of interactions between entities.

Step 4: Integrate Structured and Unstructured Data

  • Linking Nodes: Find commonalities or reference points between your structured and unstructured data nodes. For example, a customer ID in your structured data might link to a customer’s mention in unstructured data.
  • Creating Cross-Data Edges: Establish edges that connect nodes derived from structured data with those from unstructured sources, enriching the context and depth of your graph.

Step 5: Validate and Iterate

  • Test Queries: Run queries on your knowledge graph to ensure it accurately represents your data and can yield meaningful insights.
  • Iterative Refinement: As you explore the graph, you may discover opportunities to refine or expand it. This iterative process is crucial for enhancing the graph’s accuracy and usefulness.

Midjourney depiction of knowledge graph usage examples

Knowledge Graph Usage Example

To illustrate the practical application of building and using a knowledge graph, let’s explore a fictional example. This will demonstrate how a knowledge graph can provide insights and enhance decision-making.

Imagine a retail company looking to improve its customer experience and product offerings. The company has access to structured data, such as customer purchase histories and product details, and unstructured data, including customer reviews and feedback on social media.

The primary goal is to create a knowledge graph that links customer information (structured data) with their feedback and reviews (unstructured data) to gain a holistic view of customer satisfaction and product performance.

Step-by-Step Construction

Data Collection and Preparation:

11 Strategies for Unifying Structured and Unstructured Data in Generative AI The convergence of structured and unstructured data represents a pivotal moment in the evolution of Generative AI
  • Structured data: Extract customer profiles and purchase histories from the company’s database.
  • Unstructured data: Gather customer reviews and feedback from various platforms, including social media and the company’s website.

Knowledge Graph Construction:

  • Nodes creation: Establish nodes for customers, products, and feedback comments.
  • Edges creation: Link customers to their purchases, purchases to products, and customers to their feedback.
  • Data integration: Use NLP techniques to extract sentiments and key themes from customer feedback, linking these as attributes or separate nodes connected to specific products or services.

Querying and Analysis:

  • Identify products with the highest positive or negative sentiments.
  • Analyze the correlation between customer purchase behavior and feedback sentiments.
  • Discover patterns in feedback related to specific product features or customer demographics.

Insights Gained

The knowledge graph reveals that certain products, despite having high sales, receive predominantly negative feedback, pinpointing potential areas for quality improvement. This fictional retail company was also able to identify customer segments that frequently provide feedback, which enables targeted engagement strategies.

Impact on Decision-Making

The company adjusts its inventory and marketing focus based on insights into product performance and customer satisfaction. Customer service strategies are refined to address the most common issues and concerns raised in feedback, improving overall customer satisfaction.


This fictional case study demonstrates how a knowledge graph can seamlessly integrate structured and unstructured data to provide comprehensive insights. By connecting customer profiles and transactions with their feedback, the company gains a 360-degree view of its products and services.

Scaling Your Knowledge Graph

As you become more adept at managing and extracting insights from your knowledge graph, the next logical step is to scale it. Expanding your knowledge graph can involve incorporating more data sources, enhancing the graph’s complexity, or improving its integration capabilities. However, scaling comes with its own set of challenges.

Expanding Data Sources

To enrich your knowledge graph, consider integrating more structured and unstructured data sources. This could include new databases, social media feeds, text documents, or even real-time data streams.

As you add more data, maintaining high data quality becomes crucial. Implement processes to continually clean, validate, and normalize incoming data to ensure the integrity of your knowledge graph.

Increasing Complexity

As your graph grows, you can introduce more nuanced relationships and entity types, increasing the graph’s complexity to capture more detailed and sophisticated insights.

With a more complex graph, you can employ advanced analytical techniques, such as machine learning algorithms, to uncover deeper patterns and predictions within your data.

Improving Integration

Ensure that your knowledge graph can effectively integrate with other systems and data sources, facilitating a seamless flow of information across different platforms and tools. Develop APIs to allow other applications to query and interact with your knowledge graph, enhancing its utility across your organization or user base.

Addressing Challenges of Scaling

As the graph grows, implement efficient storage, indexing (such as Bitmap indexes, Adjacency indexes, Labeling schemes, or Materialized views), and query optimization techniques to manage the increased load. You should also implement robust access controls, encryption, and data anonymization techniques to safeguard privacy and sensitive information.

Going Forward with Knowledge Graphs

The journey to building and using a knowledge graph is iterative and evolving. With each new data point, relationship, and analysis, your knowledge graph becomes a more powerful tool for uncovering insights, informing decisions, and driving innovation.

Knowledge graphs offer a unique opportunity to harness the full potential of your data. By linking structured and unstructured data, you can unlock a holistic understanding of the information at your disposal, paving the way for discoveries that can propel your projects, research, or business forward.

Midjourney depiction of building a knowledge graph

Appendix: Common Technologies and Libraries Used to Build Knowledge Graphs

1. RDF (Resource Description Framework):
– Standard model for representing knowledge graphs
– Triple-based structure (subject, predicate, object)
– Serialization formats: RDF/XML, Turtle, JSON-LD

2. OWL (Ontology Web Language):
– Ontology language built on RDF
– Defines classes, properties, and relationships
– Supports reasoning and inference

3. SPARQL (SPARQL Protocol and RDF Query Language):
– Standard query language for RDF graphs
– Retrieves and manipulates data based on patterns
– Supports complex graph traversal and joining

4. Apache Jena:
– Java framework for semantic web applications
– APIs for working with RDF, OWL, and SPARQL
– Tools for reasoning, persistence, and integration

5. Neo4j:
– Graph database platform for knowledge graphs
– Property graph model with nodes and relationships
– Cypher query language for graph traversal
– Scalable and offers graph algorithms

6. GraphDB:
– Semantic graph database supporting RDF, OWL, SPARQL
– Scalable platform for large knowledge graphs
– Reasoning and inference capabilities
– Features like versioning and access control

7. AllegroGraph:
– High-performance semantic graph database
– Supports RDF, OWL, SPARQL, and Prolog
– Scalable and distributed architecture
– Advanced features: geospatial reasoning, social network analysis