Referencing or embedding documents in mongodb and couchdb

2

I'm thinking of creating referenced documents instead of embedded because I have a database in which an airplane has flights and flights have airports. Anyone experienced that could indicate the best option?

Imagine that I choose the referenced, the reference would be the foreign key in a relational database, ie just export the mysql JSON document with the secondary keys and just load it for the right collections? the references are not necessarily linked in the system, it's just an id that's there if you need a query for what I realized right? As my goal is a comparative study with mysql I have to make similar queries and take time but I've already seen that with referenced documents I had to do more than one query, is that so?

In relation to embedded already I researched and I can not understand how I will load different JSON and point out that it is contained within another one.

This is for mongodb. Regarding the couchdb does anyone know how this reference between collections is made? so I read it is not as trivial as in mongodb.

    
asked by anonymous 25.09.2015 / 04:46

1 answer

-1

Live,

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

eg MongoDB

db_x
|- collection_01
|- collection_02

In CouchDB I use prefixes:

db_x_collection_01
db_x_collection_02

Or something like that.

For embedded docs, this is an issue that does not have the right answers. It all depends on how your data will be consumed. This is the best tip I can give.

If there are many queries to db that need all docs, it is best to embed them, if it is more frequent, it is to ask for doc A and from time to time the doc A->1 , then you can reference, knowing that couchdb allows the fetch of n docs at the same time.

I hope I have helped.

    
30.07.2018 / 12:52