TyKonKet
TyKonKet

Reputation: 314

DocumentDB data structure misunderstanding

I'm starting a new website project and i would like to use DocumentDB as database instead of traditional RDBMS.

I will need two kind of documents to store:

  1. User documents, they will hold all the user data.
  2. Survey documents, that will hold all data about survays.

May i put both kind in a single collection or should i create one collection for each?

Upvotes: 1

Views: 94

Answers (1)

David Makogon
David Makogon

Reputation: 71026

How you do this is totally up to you - it's a fairly broad question, and there are good reasons for combining, and good reasons for separating. But objectively, you'll have some specific things to consider:

  • Each collection has its own cost footprint (starting around $24 per collection).
  • Each collection has its own performance (RU capacity) and storage limit.
  • Documents within a collection do not have to be homogeneous - each document can have whatever properties you want. You'll likely want some type of identification property that you can query on, to differentiate document types, should you store them all in a single collection.
  • Transactions are collection-scoped. So, for example, if you're building server-side stored procedures and need to modify content across your User and Survey documents, you need to keep this in mind.

Upvotes: 2

Related Questions