• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Document types handled by MongoDB

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Does MongoDB store only JSON document type? Is it not possible to store Document types such as MS Word, Image, video or XML files in MongoDB?

Regards,
Rajesh
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Google search yields this - http://blog.mongodb.org/post/183689081/storing-large-objects-and-files-in-mongodb
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amit
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a JSON document, I can notice that its possible to write a query such as this


The reason is that the developer of the query understands that there is a key called 'by' and there are chances of some documents having value as 'coderanch'.

If I upload a non-JSON document, say a MS Word document, and it has a key called 'by' and a value as 'coderanch', the query would miss the key/value pair.

Am I right with the understanding that although MongoDB permits non-JSON document, the MongoDB is best useful for JSON documents ?

 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are getting confused over the word "document".

  • A MongoDB "document" is analogous to a "record" in a relational database table. It is formatted like JSON although the actual storage format is BSON as described here: JSON and BSON
  • A MongoDB "collection" is analogous to a relational database table i.e. it contains a lot of JSON documents.

  • It is true that MongoDB also allows you to store data in other formats e.g. using GridFS, but GridFS stores this data separately from your JSON collections. This is like BLOB storage in relational databases i.e. MongoDB doesn't know or care what's inside your files as it treats them simply as binary objects - so the file could contain image data, XML or indeed Microsoft Office data.

    So, when you talk about storing Microsoft Word "documents" in MongoDB via GridFS, what you are really talking about is storing Word files as BLOBs (actually a set of BLOB chunks). MongoDB does not see these files as JSON documents, because they are not stored as JSON documents. You should probably read through the MongoDB documentation on GridFS to get a better understanding of what it does.

    Finally, there is a "bindata" type that can be used for storing small volumes of binary data in-line within a JSON document, but I'm not sure when/how you would use this, and the binary data would still be a "black box" from MongoDB's perspective. Also, there is a size limit of 16MB for any JSON document stored within a MongoDB collection, so your binary data would have to be smaller than this limit.
     
    Rajesh So
    Ranch Hand
    Posts: 149
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Chris,
    I understand now. You are right that I was confused that Document based data bases meant any document. Thanks for correcting.
    Thanks,
    Rajesh
     
    I found a beautiful pie. And a tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic