google app engine - Data modeling in datastore -


i started using datastore, i'm still not sure few things.

i have fallowing entities:

property: {id, number, name, long, lat}

address: {name, postcodetype}

city: {name}

country: {name}

user: {name, username}

so logic behind user have multiple properties, means property hold user key.

as described above property has properties, not sure on how associate address city , country.

i think solution store keys 3 entities in property entity.

type property struct {      id         int64   `json:"id" datastore:"-"`   number     int8    `json:"number"`   name       string  `json:"name"`   long       float64 `json:"long"`   lat        float64 `json:"lat"`   addresskey *datastore.key   citykey    *datastore.key   countrykey *datastore.key   userkey    *datastore.key   createdat  time.time } 

is attempt above start or need different.

  1. a list of countries changes, programmers use enum (or goland equivalent) represent countries, instead of creating entities in datastore. can use ether 2-letter or 3-letter country codes, , save country code string property within address entity. enum can return full display name of country based on code.

  2. i don't see reason create entity cities, although can done, if necessary. usually, city saved string property, indexed if necessary, within address entity.

this means address entity may like:

address: {name, street, city, country, postcode} 
  1. going further, if each property has 1 address, may not need address entity @ all. leads simple solution:

    type property struct {      id         int64   `json:"id" datastore:"-"`   number     int8    `json:"number"`   name       string  `json:"name"`   long       float64 `json:"long"`   lat        float64 `json:"lat"`   street     string  `json:"street"`   city       string  `json:"city"`   country    string  `json:"country"`   postcode   string  `json:"postcode"`   userkey    *datastore.key   createdat  time.time } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -