grakn.ai 中的属性实例应该是单例的吗?

Are attribute instances in grakn.ai supposed to be singleton?

根据grakn docs

Attributes in a Grakn knowledge graph are modeled differently to columns in a relational database. In this example, the attribute start-date with the value of, for instance 2019-01-01, exists only once in the knowledge graph and shared among any number of instances that may own it. This is useful when we need to query the knowledge graph for anything that has the start-date attribute with value 2019-01-01. In this case, we would get all the residencies and travels that started on the first day of 2019. It's important to remember this when performing write operations on instances of an attribute type.

这会让我觉得 grakn.ai 基本上只在其数据库中只存储一次属性值。

现在我有运行以下两次

define unit sub attribute, datatype string;
define mass sub attribute, has unit, datatype double;
define modelName sub attribute, datatype string;

define product sub entity, abstract;
define cellphone sub product, has mass, has modelName;

insert
   $y 10 isa mass, has unit "kg";
   $x isa cellphone, has modelName "Cat Phone", has mass $y;

正如预期的那样,这只创建了 "modelName" 属性的一个 "Cat Phone" 实例,但是,创建了两个 "mass" 实例,值为 10 和单位 "kg"。 (见截图)

这是预期的行为还是 grakn.ai 中的属性实例(包括具有 "nested" 属性的实例)应该是单例?

您已经正确解读了 Grakn 文档!一个需要理解的重要特性,Grakn 确实将每个 "fact" 存储为每个类型的单例。在这种情况下,unit "kg" 应该只存储一次,与 mass 10 **

相同

您似乎发现了 Grakn 处理模式元素重新定义的错误。问题是由代码的以下部分 运行 两次引起的:

define unit sub attribute, datatype string;
define mass sub attribute, has unit, datatype double;
define modelName sub attribute, datatype string;

define product sub entity, abstract;
define cellphone sub product, has mass, has modelName;

Grakn 在不重新定义模式两次时表现正常,只是 运行两次 insert... 语句:

感谢您提供可重现的示例!在 https://github.com/graknlabs/grakn/issues/5411 处创建了一个问题,应尽快处理。

** 请注意,如果您想要创建一个 mass 且值 10 且具有不同的单位,那么如果您遇到一些有趣的情况,请说 lbkglb 都将连接到同一个实例 10。如果您发现这种情况对您造成困扰,请前往友好的 Grakn Slack 社区寻找一些解决方案!