# RDF

[RDF (Resource Description Framework)](https://www.w3.org/RDF/) 是一种语义化描述知识结构的标准，也是W3C制定的关于知识图谱的国际标准。具有较强的逻辑理论背景和较完善的数据模型特征。

Relation Protocol中的社交数据需要满足RDF标准的规范，包括：

## [Graph data model](https://www.w3.org/TR/rdf-concepts/#section-data-model)

> 在RDF中任何表达式的基本结构是一个三元组的集合，每个三元组由一个主体、一个谓词和一个客体组成。一系列这样的三元组被称为RDF图(更正式的定义在[第6节](http://www.w3.org/TR/rdf-concepts/#section-Graph-syntax))，这可以用具有一个节点和有向边的图来表示，在图中每个三元组用一个节点-边-节点的连接表示（故称之“图“）。

<figure><img src="/files/4jfXfhtnM2tCSPOHcg4g" alt=""><figcaption><p>图 2-1 RDF三元组</p></figcaption></figure>

> 每个三元组表示由节点连接表示的事务之间的关系一个陈述。每个三元组有三部分：
>
> 一个[主体](https://www.w3.org/TR/rdf-concepts/#dfn-subject)， 一个[客体](https://www.w3.org/TR/rdf-concepts/#dfn-object)，和 一个[谓词](https://www.w3.org/TR/rdf-concepts/#dfn-predicate)也称为[属性](https://www.w3.org/TR/rdf-concepts/#dfn-property)，它表示一个关系。
>
> 边的方向很重要：它总是指向客体。

## [RDF Schema](https://www.w3.org/TR/rdf-schema/#ch_introduction)

> RDF Schema 为RDF数据提供了数据建模词汇表。
>
> RDF Schema 的class和property系统类似于Java等面向对象编程语言的类型系统。

## [RDF triples](https://www.w3.org/TR/rdf-concepts/#section-triples)

> 一个RDF三元组(triple)包含了三个部分：
>
> * 主体，它是一个[RDF URI引用](https://www.w3.org/TR/rdf-concepts/#dfn-URI-reference)或一个[空节点](https://www.w3.org/TR/rdf-concepts/#dfn-blank-node)
> * 谓词，它是一个[RDF URI引用](https://www.w3.org/TR/rdf-concepts/#dfn-URI-reference)
> * 客体，它是一个[RDF URI引用](https://www.w3.org/TR/rdf-concepts/#dfn-URI-reference)，一个[文字](https://www.w3.org/TR/rdf-concepts/#dfn-literal)或一个[空节点](https://www.w3.org/TR/rdf-concepts/#dfn-blank-node)
>
> 一个RDF三元组通常以主体，谓词，客体的顺序书写。
>
> 谓词也被称为三元组中的属性。

## [RDF graph](https://www.w3.org/TR/rdf-concepts/#section-rdf-graph)

> 一个RDF图(graph)是一个RDF三元组的集合。
>
> 一个RDF图的"节点" 集合是图中的三元组的主体和客体的集合。

## 举个例子

Alice 关注了 Bob，用RDF描述就是：

```sparql
<http://relationlabs.ai/entity/Alice> <http://relationlabs.ai/property/follow> <http://relationlabs.ai/entity/Bob> .
```

<figure><img src="/files/XJu8dLZh3ZEhPJhy2AeB" alt=""><figcaption><p>图 2-2 follow graph</p></figcaption></figure>

## 参考文献

* <https://www.w3.org/TR/rdf-schema/>
* <https://www.w3.org/TR/rdf-concepts/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://relationlabs.gitbook.io/protocol/protocol-zh/key-concepts/rdf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
