PromptQL Logo
18 Aug, 2026

10 MIN READ

How to Build a Knowledge Graph From Existing Data

You have a data warehouse that costs more than a car. It includes a CRM, a ticketing system and a few spreadsheets that somehow became production databases. And when someone asks a question that spans two of them, the answer is still "I'll get back to you."

The problem usually isn't the data itself. It's the rigid, table-centric way it's organized. A knowledge graph models entities like customers, orders, and parts, along with the relationships between them, directly, forming a web you can traverse on the fly instead of running expensive JOINs across disconnected tables.

This guide walks through how to build one from data you already have.

Key Takeaways

Here are the core phases distilled from the full process:

  • Defining the schema: You lock in a clear, upfront domain ontology with entity types, relationships, and attributes.
  • Preparing data sources: You profile and categorize everything from SQL tables to raw text documents and existing knowledge bases.
  • Mapping with an agentic layer: An AI layer reasons over database schemas, proposing mappings from tables and foreign keys to graph classes and relationships.
  • Extracting with fine-tuned LLMs: You use specialized models for high-precision named entity and relation extraction from unstructured text.
  • Populating the graph: You deterministically transform structured data and integrate third-party knowledge bases into clean triples.
  • Resolving entities: You apply incremental clustering frameworks like FAMER to deduplicate records across sources.
  • Validating the result: You move beyond structural checks to measure semantic coherence and operational reasoning quality.

What is a knowledge graph?

A knowledge graph is a structured representation of data in which entities (people, products, events, concepts) are stored as nodes, and the relationships between them are stored as edges, allowing both facts and the connections between them to be queried directly.

Rather than forcing information into rigid rows and columns, a knowledge graph physically integrates entities with their properties and relationships, along with metadata about entity and relationship types, into a structure both people and machines can traverse.

Now, let's talk about building one from data you already have, your existing SQL tables, documents, tickets, and knowledge bases, rather than starting from a blank slate.

Illustration for At a Glance

How to Build a Knowledge Graph From Existing Data

Step 1: Identify and Prepare Your Data Sources

Illustration for Step 2: Identify and Prepare Your Data Sources

Your data is scattered across three primary source types:

  • Structured SQL tables: hold transactional and operational records governed by rigid schemas and foreign keys. For each SQL source, catalog the schema, identify key tables, and document all foreign keys. You need read-level credentials, not raw database credentials, you cannot expose a production database to an extraction process without read-replica isolation.
  • Unstructured text: arrives as incident reports, email bodies, technical logs, and PDFs with no formal data model. Constructing knowledge graphs in specialized contexts presents unique challenges: highly distributed and dynamic knowledge, limited data accessibility, and domain-specific semantic complexity. Your reports contain technical codes and operational abbreviations that generic text parsers get wrong. Collect representative samples, extraction accuracy depends on seeing the actual variation in your text early, not after you've already picked the wrong model.
  • Existing knowledge bases: like curated taxonomies, reference datasets, or public ontologies, can anchor your graph. Start with a blunt inventory. Profile each source for volume, freshness, and access.

Step 2: Define the Domain Ontology and Schema

Now lock in what you mean by "customer," "account," or "incident." Identify the core nouns in your business (Account, Part, Incident, Event) and name them as entity types, then define the verbs connecting them as relationship types (filed, purchased, reported_by).

Build this vocabulary with the people who'll actually query the data, and treat it as provisional until it's been checked against the real schemas and text samples from step 1, not locked in before you've looked at the data. Enforce this schema during ingestion. Letting an LLM invent ad-hoc classes on the fly is how you end up with several differently named nodes for the same concept, which quietly makes your graph unanswerable.

Step 3: Map Sources to a Semantic Schema with an Agentic Layer

A human analyst used to park in front of a DDL file and hand-wire every `order_header` column to an `Order` class. The work ate weeks of calendar time and broke the instant a schema changed. Here is the automated path I use now instead. An agentic layer reads the database catalog and proposes the graph mapping. The human reviews it. The whole loop takes minutes.

  1. Ingest the database catalog: Feed the agentic layer the table schemas, primary keys, foreign key relationships, and sample data from each structured source.
  2. Reason over the structure: Let the agent propose a preliminary mapping. Tables become node labels. Rows become nodes. Columns become node properties.
  3. Resolve foreign keys: Instruct the agent to analyze foreign keys and map them directly to graph relationships. Foreign keys are replaced with relationships to the other table, then removed as individual properties.
  4. Transform JOIN tables: Teach the agent to recognize bridge tables. JOIN tables are transformed into relationships, and columns on those tables become relationship properties.
  5. Publish the mapping contract: Output a machine-readable mapping file that the graph population engine in Step 5 executes deterministically. Reviewing this contract as a human takes minutes, not days.

Step 4: Extract Entities and Relationships from Unstructured Text with Fine-Tuned LLMs

Illustration for Step 4: Extract Entities and Relationships from Unstructured Text with Fine-Tuned LLMs

Forget running a raw PDF through a general-purpose chatbot. Accuracy drops fast on domain-specific terms, technical codes, and operational abbreviations. You need a fine-tuned model instead.

2026 research published in Scientific Reports confirms why: a model fine-tuned for specialized knowledge graph construction achieves substantial gains in relationship extraction accuracy over off-the-shelf baselines. In operational text where a single misread part code can break a dependency chain, that precision is the whole project.

Preliminary results show that combining parsing trees with entity coreference resolution improves extraction effectiveness further. The practical takeaway: pair syntactic structure with coreference resolution rather than relying on raw text extraction alone.

Step 5: Populate the Graph from Structured Data and Knowledge Integration Pipelines

Illustration for Step 5: Populate the Graph from Structured Data and Knowledge Integration Pipelines

This is where the graph actually comes together, and it needs both outputs, not just the structured half:

  1. Transform each mapped row to a node: for every row in a mapped table, create a node with the corresponding label, and assign non-key columns as node properties.
  2. Materialize relationships: for each foreign key relationship in the mapping, create an edge between parent and child nodes.
  3. Merge in the unstructured extraction output: take the triples extracted in step 4 and write them into the same graph, so structured and unstructured data land in one place instead of staying as two disconnected outputs.
  4. Ingest external knowledge bases: pull in any reference taxonomies or public authority data you profiled in step 1.
  5. Enforce the ontology: as each triple writes, validate that the subject type, object type, and predicate all conform to the schema from step 2. Reject anything that doesn't to a review queue instead of letting the graph quietly drift.

Step 6: Resolve entities and validate, on an ongoing basis

Illustration for Step 7: Assess Semantic Coherence and Operational Reasoning Quality

The moment you integrate a second source, you create duplicates. A customer record from your CRM is not a different entity from the same customer in your billing system, even if the names are formatted differently. Entity resolution identifies records across sources that refer to the same real-world object, and it's where most knowledge graph projects quietly fail. A naive approach, adding each new entity to the closest existing cluster or creating a new one, degrades as more sources pile on, with cluster quality becoming dependent on the order entities were inserted in.

Incremental clustering frameworks like FAMER solve this with n-depth reclustering, which repairs existing clusters as new data arrives instead of leaving quality dependent on insertion order, matching the quality of batch-style resolution while running incrementally.

Once entities are resolved, validate beyond structure:

  • Semantic coherence: check that inferred paths reflect logical domain constraints, for example, verifying that an "Incident reported_by Employee" path always connects to a node whose employee ID actually exists.
  • Operational reasoning: pose complex business questions spanning three or more relationship types, like "which product lines generated the most support incidents but also had the shortest time to ship," to confirm the graph traverses and reasons correctly.

This isn't a step you complete once. Every new source or data change should re-trigger both resolution and validation, not just the first time the graph gets built.

To validate that the graph works beyond structural correctness, follow these steps:

  • Semantic coherence: Check that inferred paths reflect logical domain constraints, for example verifying that the path "Incident -> reported_by -> Employee" always connects to a node whose employee ID exists.
  • Operational reasoning: Pose complex business questions spanning three or more step types, such as "Which product lines generated the most support incidents but also had the shortest time-to-ship?" to confirm correct graph traversal and business logic.
  • Validation and use: Tools like metaphants provide a visual query interface for these reasoning tests; a validated graph immediately enhances semantic search, recommendation systems, and question-answering applications.

Common mistakes when building from existing data

  • Locking the ontology before profiling the actual data, which produces a schema based on assumptions rather than what's really there
  • Treating entity resolution as a one-time step instead of a live, ongoing capability that needs to run every time a source changes
  • Letting the structured mapping pipeline and the unstructured extraction pipeline stay separate, so only part of your data ever actually makes it into the graph
  • Checking only structural metrics, like node count, instead of semantic coherence and whether the graph can actually answer real business questions

The architecture decision you need to take

Every graph built from existing data eventually forces this choice: build and maintain it yourself, following the six steps above, or connect a tool that does it for you automatically.

Building it yourself means owning ontology design, structured and unstructured mapping, population, and entity resolution as an ongoing responsibility, one that has to keep running every time a source changes, per step 6 above.

PromptQL is built to take this off your plate. It connects to your warehouses, databases, SaaS apps, and APIs as they already exist, and introspects the schemas to build a unified data graph without moving or reshaping the underlying data. It also seeds business context directly from Slack, Google Drive, and GitHub, so structured and unstructured sources feed one graph automatically instead of needing the two separate pipelines described in steps 3 and 4.

Conclusion

Building a knowledge graph from existing data is less about graph theory and more about discipline: profile before you design, keep entity resolution running instead of treating it as a checkbox, and make sure structured and unstructured data actually end up in the same graph. Get that sequence right, and you close the gap between a report that used to take two weeks and an answer that now takes two seconds.

Frequently Asked Questions

What is a knowledge graph and how does it compare to a traditional database?

A knowledge graph uses nodes (entities) and edges (relationships) to model data directly, rather than forcing information into rigid tables and rows. A traditional database depends on costly JOIN operations to connect data across tables. Knowledge graphs physically store these connections, enabling significantly faster traversal for interconnected queries.

What are the main data sources you can use to populate a knowledge graph?

You populate a graph from three primary sources that each require different extraction and resolution techniques.

  • Structured databases: SQL tables with transactional and operational records
  • Unstructured text: reports, emails, and PDFs with no formal data model
  • Pre-existing knowledge bases: curated taxonomies, reference datasets, or public ontologies

What is the step-by-step process for building a knowledge graph from structured data like SQL tables?

Convert a relational database into graph triples with this deterministic three-step pipeline.

  1. Map entity tables to node labels: map each entity table to a node label and each row to a node with columns as properties
  2. Replace foreign keys with direct relationships: replace foreign keys with direct relationships to the target table
  3. Convert JOIN tables into relationship properties: transform JOIN tables from intermediary tables into relationship properties

How can you extract entities and relationships from unstructured text using AI or NLP?

Use a fine-tuned LLM rather than a generic one, supported by three key findings from 2026 research.

  • Fine-tuned LLMs: achieve substantial gains in relationship extraction accuracy on specialized documents where general-purpose models break down on technical codes and abbreviations
  • Parsing trees with coreference: combining parsing trees with entity coreference resolution further improves ranking effectiveness
  • Domain-specific terms: general-purpose models fail on technical codes and operational abbreviations present in specialized texts

What are the best practices for schema design and entity resolution when building a knowledge graph?

Two critical principles govern successful knowledge graph construction.

  • Define ontology upfront: use strict entity types and relationships; do not let AI invent classes on the fly
  • Use incremental clustering frameworks: frameworks like FAMER with n-depth reclustering repair outperform naive methods by fixing cluster quality regardless of source insertion order

What are the current leading tools, both open-source and commercial, for constructing knowledge graphs in 2026?

Open-source frameworks like FAMER lead in parallel, scalable entity clustering and incremental resolution. Commercially, platforms like metaphacts provide visualization and semantic layer tooling. Graph databases such as Neo4j and Oracle's property graph features in its Always Free autonomous database support native graph storage and querying with PGQL.

Sources

  1. Incremental Multi-source Entity Resolution for Knowledge Graph Completion - PMC - pmc.ncbi.nlm.nih.gov
  2. ETD | Hierarchical Entity Extraction and Ranking with Unsupervised Graph Convolutions | ID: b8515p57p | Emory Theses and Dissertations - etd.library.emory.edu
  3. The construction and refined extraction techniques of ... - www.nature.com
  4. Incremental Multi-source Entity Resolution for Knowledge Graph Completion | The Semantic Web - dl.acm.org
  5. [2101.06126] EAGER: Embedding-Assisted Entity Resolution for Knowledge Graphs - arxiv.org
  6. RDBMS & Graphs: Relational vs. graph data modeling - neo4j.com
  7. Create a Knowledge Graph with Oracle Autonomous Database and Property Graph Query Language - docs.oracle.com
PromptQL Team
PromptQL Team
Pre Footer

See PromptQL in action on your data.