I'm new to NoSQL. I have this question all the time. As we all know in SQL, data are store in tables where except the first row, are only data. In contrast, NoSQL stores data in Object, which contain at least one pair of key-value. Does NoSQL repeatly store all keys of every document in storage? If so, can I affirm that SQL is better than NoSQL in terms of storage efficiency?
Here NoSQL, I mean MongoDB. Sorry for the confusion.
I think what you are mainly asking is if you have for example 1 million documents with 20 keys(fields) each, if MongoDB will save 20 million strings also for your collection plus all the values.
There is a simple way to test it, dont know how realiable but you can make 1 collection with 1 big key, and save 1 million documents for example, and check the size of the collection on
/var/lib/mongodb
MongoDB compress the data Compression in MongoDB collections
I don't know details of how it works, but i think that compression reduce the disk space of keys. I guess it will similar to a zip file, that when we store 1 word many times, only 1 time is saved, and even a file 20MB becomes few kb.
Its better to wait for better answers or to ask here also, there are people there that know all details of how MongoDB stores data.Ask them about keys storage.