我正在使用 Google App Engine 和 Big Table。
我有一个person
看起来像这样的实体:
{
// This property would be encoded into JSON and saved un-indexed as db.Text()
phone_numbers:
{
'hHklams8akjJkaJSL': // <-- Should I key this object?
{
number:'555-555-5555',
type:'mobile',
},
etc...
},
// This property is an array of strings.
// It is searchable so that a query could be run to find all
// people with a particular phone number:
// "SELECT * FROM person WHERE phone_number_search_property =
// '5555555555'"
phone_number_search_property:['5555555555','other phone numbers...'],
first_name:'...',
etc...
}
该phone_number
属性存储为 JSON 格式 (db.Text) 的未索引文本块。如果我想在这种情况下引用特定的电话号码,我会解码 json,然后使用我正在寻找的特定密钥获取电话号码。
phone_number_search_property
用于搜索。它可以通过电话号码进行搜索:"SELECT * FROM person WHERE phone_number_search_property = '5555555555'"
在这种情况下,引用实体内部电话号码的好方法是什么?在这里,我使用 UUID 键入每个值。这是一种“正常”且被接受的做事方式吗?如果不是,那是什么?
谢谢!