Couchbase Data Structure Design: Flat vs Nested Documents?

Mostly just the extra bytes. Is there any value in grouping the timestamps? Do you always want to have to refer to the lastEdited timestamp as timeStamps.lastEdited?

Indexing depends on the indexes you are using, and indexes depends on how you want to query. It doesn’t matter to the indexer if the index is on timeStamps.lastEdited or lastEdited. Likewise metadata.metadataTitle vs metadataTitle. It’s not likely that indexing on all of metadata would be useful - because you probably want to be able to query on individual attributes

Beyond that, there are the same advantages as any structured data (xml, json etc).
The one difference I see is that with the nested form, you could get all the metadata with ‘metadata’ (or metadata.*), which could be useful if additional metadata attributres were added.

1 Like