# 三元组存储

三元组存储是一种数据库，专门用于存储和检索 RDF 三元组——即以主语-谓语-宾语形式编码事实的原子陈述——并针对这些三元组回答查询，查询通常用 SPARQL 查询语言编写。它也被称为 RDF 存储；当它对数据附加形式化推理时，则称为 RDF 图数据库。<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup><sup> • </sup><sup>[2](https://pubs.usgs.gov/of/2015/1004/pdf/ofr2015-1004.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 数据模型 | RDF 三元组：主语-谓语-宾语陈述，如“杰西卡教授计算机科学”；陈述的集合构成一张事实图<sup>[3](https://www.dataversity.net/articles/triplestores-101-storing-data-efficient-inferencing/)</sup> |
| 查询语言 | SPARQL，W3C 的正式推荐标准，由三元组模式、合取和 URI 前缀定义构成<sup>[2](https://pubs.usgs.gov/of/2015/1004/pdf/ofr2015-1004.pdf)</sup><sup> • </sup><sup>[4](https://www.dcc.fc.up.pt/~ricroc/homepage/publications/2013-SLATE-A.pdf)</sup> |
| 索引 | 在三个位置上建立多个索引，常见排序为 SPO、POS 和 OSP，使任何绑定与未绑定位置任意组合的三元组模式都能被快速应答<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup> |
| 四元组 | 多数三元组存储将三元组扩展为四元组，加入第四个元素——命名图 URI，以处理来源、版本管理和数据集隔离<sup>[5](https://inferensys.com/glossary/clinical-workflow-automation/healthcare-knowledge-graphs/triplestore)</sup> |
| 示例系统 | Apache Jena（含 TDB 与 Fuseki）、Blazegraph、Stardog、Ontotext GraphDB、Virtuoso，以及研究系统 RDF-3X<sup>[6](https://people.cs.aau.dk/~matteo/pdf/SEBD22-RDFstorage.pdf)</sup><sup> • </sup><sup>[7](https://yjtoon.com/catalog/database-types/graph-databases-comparison/)</sup> |
| 区别性特征 | 共享词表、本体和形式化推理，这使 RDF 存储成为知识图谱与跨组织数据整合的天然归宿<sup>[8](https://www.ciopages.com/buyer-guides/graph-database)</sup> |

## 三元组存储的工作原理

三元组存储将每条事实存为一条具有三个位置的陈述：主语标识被描述的事物，谓语命名关系或属性，宾语给出值或相关资源。查询通过将三元组模式与存储进行匹配来应答，其中三个位置中的任何一个都可以绑定到具体值，或作为变量保持未绑定。<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup>

为使这种匹配无论哪些位置被绑定都能保持快速，三元组存储通常会在三个位置上维护若干索引。常见的索引排序包括 SPO、POS 和 OSP，即主语、谓语、宾语的三种排列，这样，任何绑定与未绑定位置组合的模式都无需扫描整个数据集即可应答。<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup> 研究系统还探索过其他组织方式：k2-triples 技术利用谓语将数据集垂直划分为互不相交的（主语，宾语）对子集，每个谓语一个子集，从而在压缩空间中支持高效的 SPARQL 求解。<sup>[9](https://arxiv.org/abs/1310.4954)</sup>

**四元组与命名图。** 为了追踪数据来源、管理版本并保持数据集相互分离，多数三元组存储通过添加第四个组成部分将每个三元组扩展为四元组：命名图 URI，它将陈述归集成单一存储内的命名数据集。<sup>[5](https://inferensys.com/glossary/clinical-workflow-automation/healthcare-knowledge-graphs/triplestore)</sup> 例如，[Blazegraph](https://www.edgepedia.org/zh/blazegraph) 被描述为支持上下文的 RDF 四元组存储，支持 SPARQL 1.1 查询，并通过 [Elasticsearch](https://www.edgepedia.org/zh/elasticsearch) 提供全文检索，另有地理空间功能。<sup>[7](https://yjtoon.com/catalog/database-types/graph-databases-comparison/)</sup>

## SPARQL 与语义网技术栈

SPARQL（SPARQL 协议与 RDF 查询语言）是 RDF 的标准查询语言。正如 SQL 为关系数据库系统提供查询语言，SPARQL 为三元组存储提供查询语言，并且是 W3C 的正式推荐标准。该语言由三元组模式、合取（逻辑“与”），以及定义 URI 前缀和相对于一组前缀标识资源 URI 的机制构成。<sup>[4](https://www.dcc.fc.up.pt/~ricroc/homepage/publications/2013-SLATE-A.pdf)</sup> SPARQL 端点是一种符合规范的 SPARQL 协议服务，用于查询知识库，结果通常以一种或多种机器可处理的格式返回。<sup>[2](https://pubs.usgs.gov/of/2015/1004/pdf/ofr2015-1004.pdf)</sup>

三元组存储位于语义网技术栈之中，该技术栈还包括 RDFS——一种对本体的初步表示——以及更具表达力的本体语言。3XL 系统旨在支持对海量 OWL Lite 三元组的高效操作；其实验表明，加载和查询性能可与最好的基于文件的三元组存储相媲美，并优于其他基于 DBMS 的三元组存储。<sup>[10](https://www.sciencedirect.com/science/article/abs/pii/S030643791000133X)</sup>

## 三元组存储与属性图数据库

三元组存储是图数据库两大主导家族之一。另一家族是属性图数据库，如 Neo4j，它存储带标签的节点和边及其属性，用 Cypher、Gremlin 或 GQL 查询。这两个家族分别对应两种图数据模型——RDF 与带标签属性图——适合不同的工作负载。<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup> 当不需要形式化推理和跨组织链接时，属性图数据库适合具有深层遍历和丰富边数据的应用图；当共享词表、本体和形式化推理至关重要时，RDF 三元组存储则更为合适。<sup>[1](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)</sup><sup> • </sup><sup>[8](https://www.ciopages.com/buyer-guides/graph-database)</sup>

RDF 背后的标准也改变了切换产品的成本。在 RDF 存储之间迁移，例如从 Jena 迁到 GraphDB 再迁到 Stardog，很大程度上只是重新导入标准的 Turtle 或 [N-Triples](https://www.edgepedia.org/zh/n-triples) 数据；而离开属性图厂商则可能意味着在应用代码中重新实现推理。<sup>[11](https://kindatechnical.com/knowledge-graphs/comparing-knowledge-graph-database-options.html)</sup>

三元组存储通常不被描述为“原生”图数据库，因为它们存储三元组并匹配三元组模式，而不是直接存储图结构以进行指针追逐式遍历；但就其陈述集合构成一张事实图而言，它们仍然是图数据库引擎。<sup>[3](https://www.dataversity.net/articles/triplestores-101-storing-data-efficient-inferencing/)</sup><sup> • </sup><sup>[12](https://www.ontotext.com/blog/triplestores-are-proven-as-operational-graph-databases/?generate_pdf=8955)</sup>

## 用例与规模

三元组存储用于数据间关系承载价值、跨词表整合至关重要的场合：为人工智能提供知识图谱、欺诈检测，以及生物医学和基因组学等领域的科学数据整合。<sup>[8](https://www.ciopages.com/buyer-guides/graph-database)</sup><sup> • </sup><sup>[7](https://yjtoon.com/catalog/database-types/graph-databases-comparison/)</sup> 以抽象三元组形式表达数据，可以带来更大的灵活性，并使查询能在不同数据库间复用；三元组存储的优点是极为灵活，是存储不适合固定关系模式的边缘数据的极佳方式。<sup>[13](https://www.w3.org/2007/03/VLDB/)</sup>

在大规模场景下，索引和查询处理成为核心研究问题。存储、索引和处理 RDF 数据集的 RDF 数据管理系统一直是语义网领域的核心研究兴趣，人们提出了基于顶点、谓语以及图或关系信息集合的索引方法，以支持分布式仓库和对大规模 RDF 的高性能查询处理。<sup>[14](https://journals.sagepub.com/doi/10.3233/IFS-131039)</sup> 各类实现涵盖学术原型如 RDF-3X、社区项目如 Jena TDB，以及商业产品如 Virtuoso 和 GraphDB，它们利用了各不相同的数据表示与索引方案。<sup>[6](https://people.cs.aau.dk/~matteo/pdf/SEBD22-RDFstorage.pdf)</sup> 对于更大规模的部署，建议使用 Jena 搭配外部三元组存储，如 Blazegraph 或 Stardog。<sup>[7](https://yjtoon.com/catalog/database-types/graph-databases-comparison/)</sup>

## References

1. [Triple Stores vs Property Graph Databases, kindatechnical()](https://kindatechnical.com/knowledge-graphs/triple-stores-vs-property-graph-databases.html)
2. [World Wide Web Consortium, 2008, SPARQL query language for RDF, USGS Open-File Report 2015-1004](https://pubs.usgs.gov/of/2015/1004/pdf/ofr2015-1004.pdf)
3. [Triplestores 101: Storing Data for Efficient Inferencing, Dataversity](https://www.dataversity.net/articles/triplestores-101-storing-data-efficient-inferencing/)
4. [2nd Symposium on Languages, Applications and Technologies (SLATE) paper](https://www.dcc.fc.up.pt/~ricroc/homepage/publications/2013-SLATE-A.pdf)
5. [What is a Triplestore? Definition & Use Cases, Inference Systems](https://inferensys.com/glossary/clinical-workflow-automation/healthcare-knowledge-graphs/triplestore)
6. [Understanding RDF Data Representations in Triplestores, Aalborg University](https://people.cs.aau.dk/~matteo/pdf/SEBD22-RDFstorage.pdf)
7. [Graph Databases Comparison, yjtoon.com](https://yjtoon.com/catalog/database-types/graph-databases-comparison/)
8. [Buyer's Guide: Graph Database Platforms, CIOPages](https://www.ciopages.com/buyer-guides/graph-database)
9. [Compressed Vertical Partitioning for Full-In-Memory RDF Management, arXiv](https://arxiv.org/abs/1310.4954)
10. [3XL: Supporting efficient operations on very large OWL Lite triple-stores, Information Systems](https://www.sciencedirect.com/science/article/abs/pii/S030643791000133X)
11. [Comparing Knowledge Graph Database Options, kindatechnical()](https://kindatechnical.com/knowledge-graphs/comparing-knowledge-graph-database-options.html)
12. [Triplestores are Proven as Operational Graph Databases, Ontotext](https://www.ontotext.com/blog/triplestores-are-proven-as-operational-graph-databases/?generate_pdf=8955)
13. [RDF and SPARQL: Using Semantic Web Technology to Integrate the World's Data, W3C](https://www.w3.org/2007/03/VLDB/)
14. [Indexing and querying algorithm based on structure indexing for managing massive-scale RDF data, Journal of Intelligent & Fuzzy Systems](https://journals.sagepub.com/doi/10.3233/IFS-131039)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 11, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Database engines and systems › Graph databases

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/triplestore

English original: https://www.edgepedia.org/triplestore
