Reference or embed documents in mongodb and couchdb

Asked

Viewed 225 times

2

I’m thinking of creating referenced documents instead of embedded because I have a database where a plane has flights and flights have airports. Someone experienced enough to tell me the best option?

Let’s imagine that I choose the referenced ones, the reference would be the foreign key in a relational database or simply export the mysql JSON document with the secondary keys and just click to the collections right? references are not necessarily connected in the system, it’s just an id that is there if a query is needed as I understood right? As my goal is a comparative study with mysql I have to make similar queries and take times but I’ve seen that with referenced documents had to do more than one query, that’s just it?

Regarding the embedded already researched and I can not understand how I will load different JSON and point out that that is contained inside another.

This for mongodb. Regarding couchdb, does anyone have any idea how this reference is made between collections? by what I read is not as trivial as in mongodb.

  • Solved your doubt?

1 answer

-1

Long live,

in couchdb there is no notion of collections as in mongodb. In couchdb you have to create 1 db for each mongodb Collection.

ex.: Mongodb

db_x
|- collection_01
|- collection_02

In Couchdb I use prefixes:

db_x_collection_01
db_x_collection_02

Or something like that.

Regarding embedded Ocds, this is a question that has no right answers. Everything will depend on how your data will be consumed. This is the best tip I can give.

If there are many querys a db that needs all the Docs, it is best to embed, if most often, is to ask for doc A and from time to time doc A->1, then can refer, knowing that the couchdb allows the fetch of n Docs at the same time.

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.