简体   繁体   中英

Storing data in XML or MongoDB

Here is my use-case.

  1. I have some data, which I am storing now in the xml files. The data that I am storing is not persistent ie I would be deleting the user data once the user logs out.
  2. My server communicates with the client using the XML requests and responses. So initially we decided, since we are sending the XML as response, lets store it in XML so that conversion from database to XML format time is saved.
  3. The client will request for XML based on some filter conditions. So I will have to use XQUERY.
  4. A maximum of 100 entries will be there in an XML, atleast as of now.

Now I would like to hear some advice on whether I should use XML or MongoDB. My Concerns :

  1. How good is it to store temporary data in MongoDB and delete/take backup once done with session?
  2. Conversion from MongoDB json format to XML.
  3. Handling the changes in the schema design.

I can't use any other DB than MongoDB, as some persistent operations are still done on MongoDB.

Thanks in advance.

You are most likely better off using MongoDB to handle your session data. There should be no problem in creating and removing objects based on session starting or session ending. You will be taking advantage of the high performance MongoDB which will give you scalability to grow over time.

Depending on your language of choice, (I use C#) you might get the ability to serialize Json into an object without any performance penalty. The C# driver for example, handles the serialization for you, so every object you retrieve from Mongo will be automatically represented as a C# object. The same way you can populate your C# object and store it in the database, all handled by the driver.

If you manage your data through objects to serialize/deserialize to and from mongodb, you can actually serialize/deserialize to XML as well. So the same objects you use for Mongo can be used to manage your xml.

So to answer your questions:

  1. How good is it to store temporary data in MongoDB and delete/take backup once done with session? Should be as suitable as any other database. Definitely better than storing data in XML files on the server.

  2. Conversion from MongoDB json format to XML. Depending on your mongodb driver, you can use objects and serialize/deserialize to mongodb and xml at the same time, making your conversion from xml to mongodb back and forth very easy.

  3. Handling the changes in the schema design. Mongo is schema-less because it uses documents instead of tables. Any change in the document structure will be handled by mongoDB since there is no schema like in a relational database.

I hope this makes some sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM