简体   繁体   English

实体Google数据存储区是否可以具有“空”属性?

[英]Does the entity google datastore could have “empty” property?

If I have an employee entity with A,B and C properties and there is a certain kind of employee that have a property D. Which is better to do 如果我有一个具有A,B和C属性的雇员实体,并且某某类雇员具有属性D。

  1. To make two entities employee and d_employee. 使两个实体成为雇员和d_employee。
  2. add the property D into the entity employee. 将属性D添加到实体员工中。

What I'm concerned with if I follow the second solution is that all the employee entities may have a redundant property D (From Relational database prospective: Empty row) Is this true? 如果遵循第二种解决方案,我会担心的是所有雇员实体可能都具有冗余属性D(来自关系数据库预期对象:空行)这是真的吗? I searched for an answer in the documentation but it's not clear what will exactly happen in this case. 我在文档中搜索了答案,但尚不清楚在这种情况下究竟会发生什么。

  1. add the property D into the entity employee. 将属性D添加到实体员工中。

Google's datastore is not a relational database based on tables. Google的数据存储区不是基于表的关系数据库。 It stores entities as separate "documents" and has no requirement that those documents are in any way similar to each other besides having the same id types. 它将实体存储为单独的“文档”,并且不要求这些文档除了具有相同的id类型以外,在任何方面都彼此相似。

Having no table schema also means you can do other interesting things like indexing properties selectively per entity. 没有表架构也意味着您可以做其他有趣的事情,例如为每个实体选择性地建立索引属性。 There is no column that could be set to be indexed. 没有可以设置为索引的列。

Objectify's polymorphism feature allows to implement different types of data in the same "table" (or a better word for that if you find one). Objectify的多态性功能允许在同一张“表”中实现不同类型的数据(如果找到一个表,则可以使用一个更好的词)。 In case you don't use objectify, have a look at it. 如果您不使用对象化,请看一下。 It's also good for storing simple entities with "optional" fields (there are no table constraints either, so simply having things null works). 这对于存储带有“可选”字段的简单实体也很好(也没有表约束,因此简单地使null有效)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM