简体   繁体   中英

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

  1. To make two entities employee and d_employee.
  2. add the property D into the entity employee.

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? 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.

Google's datastore is not a relational database based on tables. 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.

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). 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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