简体   繁体   English

以XML或MongoDB存储数据

[英]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. 我有一些数据,这些数据现在存储在xml文件中。 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. 我的服务器使用XML请求和响应与客户端进行通信。 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. 因此,最初我们决定,因为我们将XML发送为响应,所以将其存储在XML中,从而节省了从数据库到XML格式的转换时间。
  3. The client will request for XML based on some filter conditions. 客户端将根据某些过滤条件请求XML。 So I will have to use XQUERY. 因此,我将不得不使用XQUERY。
  4. A maximum of 100 entries will be there in an XML, atleast as of now. 到目前为止,XML中最多有100个条目。

Now I would like to hear some advice on whether I should use XML or MongoDB. 现在,我想听听有关我应该使用XML还是MongoDB的一些建议。 My Concerns : 我的关注:

  1. How good is it to store temporary data in MongoDB and delete/take backup once done with session? 在会话中完成后,将临时数据存储在MongoDB中并删除/获取备份有多好?
  2. Conversion from MongoDB json format to XML. 从MongoDB json格式转换为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. 我不能使用MongoDB以外的任何其他数据库,因为某些持久性操作仍在MongoDB上完成。

Thanks in advance. 提前致谢。

You are most likely better off using MongoDB to handle your session data. 使用MongoDB处理会话数据很可能会更好。 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. 您将利用高性能的MongoDB,它将为您提供可伸缩性,以随着时间的推移而增长。

Depending on your language of choice, (I use C#) you might get the ability to serialize Json into an object without any performance penalty. 根据您选择的语言(我使用C#),您可能会获得将Json序列化为对象的能力,而不会降低性能。 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. 例如,C#驱动程序为您处理序列化,因此从Mongo检索到的每个对象都将自动表示为C#对象。 The same way you can populate your C# object and store it in the database, all handled by the driver. 您可以使用相同的方法填充C#对象并将其存储在数据库中,所有这些操作均由驱动程序处理。

If you manage your data through objects to serialize/deserialize to and from mongodb, you can actually serialize/deserialize to XML as well. 如果您通过对象管理数据以在mongodb之间进行序列化/反序列化,则实际上也可以对XML进行序列化/反序列化。 So the same objects you use for Mongo can be used to manage your xml. 因此,可以将用于Mongo的相同对象用于管理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? 在会话中完成后,将临时数据存储在MongoDB中并删除/获取备份有多好? Should be as suitable as any other database. 应该与任何其他数据库一样合适。 Definitely better than storing data in XML files on the server. 绝对比将数据存储在服务器上的XML文件中更好。

  2. Conversion from MongoDB json format to XML. 从MongoDB json格式转换为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. 根据您的mongodb驱动程序,您可以同时使用对象以及对mongodb和xml进行序列化/反序列化,从而使从xml到mongodb的来回转换非常容易。

  3. Handling the changes in the schema design. 处理模式设计中的更改。 Mongo is schema-less because it uses documents instead of tables. Mongo是无架构的,因为它使用文档而不是表。 Any change in the document structure will be handled by mongoDB since there is no schema like in a relational database. 文档结构中的任何更改都将由mongoDB处理,因为没有关系数据库中的架构。

I hope this makes some sense. 我希望这是有道理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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