2

I am storing the data for my app in Google's NDB, but am confused as to what architecture to use. The app data is mostly text based, but has some non-text properties like DateTimeProperty, FloatProperty and one or two BooleanProperty's.

I could store each property correctly (e.g. a datetime is stored as a DateTimeProperty), or I could already package all the data up as a JSON object and store it as a JsonProperty.

Storing everything as a JsonProperty gives the benefit of taking up less space (there's a compress flag that causes the content to be gzipped), but taking this approach makes it harder to search the database with query().

Which approach is better to take?

3
  • can you give us some more input on what kind of app this will be as that will play a major role in what kind of architecture might work
    – Maru
    Oct 29, 2014 at 6:18
  • 1
    @Maru I updated the question with types of data that need to be stored.
    – Ben
    Oct 29, 2014 at 6:28
  • 2
    What matters isn't the type of data you're storing, it's how you want to retrieve it. If you can get away with retrieving entities by key only, then the JSON approach would work fine. If you need any sort of query-ability, you're hosed. I think that's what @Maru was asking for. Can you update your question with that info? Oct 29, 2014 at 14:06

1 Answer 1

1

Personally, I'd go with using regular data types instead of serialising it to JSON then storing that instead as that is the most natural way to go about it plus you can index it.

Storing JSON objects have its uses too, especially if you want to make quick canned responses or if the one processing your data can readily read JSON(i.e. nodejs and its ilk) and the need to query this field doesn't exist(JSONProperty is stored as a blob, good luck indexing that)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.