可以使用Xml文件作为数据库 [英] Can Use Xml File As DataBase

查看:155
本文介绍了可以使用Xml文件作为数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

可以在小型mvc3网站上使用Xml文件吗?它有一个登录进行edite删除,并有显示新闻的页面。

解决方案

如果您的XML文件足够小,可以将所有数据保存在内存中,这是一种实现某种数据库的简单方法。并且您将享受纯粹面向对象的数据库的巨大好处,没有映射代码。但是,如果不是这种情况,这种方法会非常尴尬,我强烈反对它,推荐一些RDBMS,它可以是开源的,或多或少轻量级。



也就是说,如果使用基于XML的内存中面向对象的数据库,首先应该要求的是将存储与数据库功能完全隔离。您的数据库应该是一般形状的对象图(首先,您不应该假设它是树),并且存储应该100%与数据类型无关。这些主要目标完全满足数据合同

http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ]。



请参阅我过去的答案,我提倡这种奇妙的方法:
如何利用XML我的表单应用程序中的文件编写器和阅读器? [ ^ ],

创建属性文件...... [ ^ ]。



请注意,您不需要手动使用XML。您的对象图将完整存储,然后在内存中恢复。循环依赖(记住,我提到对象图不需要是树),这种方法仍然可以完美地工作。此外,您可以轻松地改进数据库模式,并提供与早期版本软件中创建的文件的向后兼容性。



如果主要标准(all-database-in-记忆)无法保证,我会说努力不值得努力,根本不值得。在这种情况下,请选择RDMBS。查看此套装:

http://en.wikipedia.org/wiki/List_of_relational_database_management_systems [ ^ ],

http://en.wikipedia.org/wiki/List_of_object_database_management_systems [ ^ ]。



祝你好运,

< DD> -SA

Hi every body.
Can use a Xml file for small mvc3 website?It have a Log in for edite delete ,and have pages for show news.

解决方案

If your XML file is small enough to keep all the data in memory, this is a simple easy way to implement a kind of a database; and you would enjoy the huge benefits of purely object-oriented database, no mapping code. If this is not the case, however, such approach would be very awkward, and I would strongly discourage it, recommend some RDBMS, which could be open-source and more or less light weight.

That said, if using XML-based in-memory object-oriented database, first thing you should require is total isolation of storage from database functionality. Your database should be some object graph of general shape (first of all, you should not assume it is a tree), and the storage should be 100% agnostic of data types. These primary goals are fully satisfied with Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

Please see my past answers where I advocate this wonderful approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

Note that you won''t need to work with XML manually. Your object graphs will be stored in full and later restored in memory. Circular dependencies (remember, I mentioned that the object graph is not required to be a tree), the approach will still perfectly work. Besides, you can easily evolve the database schema and provide backward compatibility with files created in earlier versions of your software.

If the main criterion (all-database-in-memory) cannot be guaranteed, I would say that the effort would not worth the effort, not at all. In this case, opt for RDMBS. Review this set:
http://en.wikipedia.org/wiki/List_of_relational_database_management_systems[^],
http://en.wikipedia.org/wiki/List_of_object_database_management_systems[^].

Good luck,
—SA


这篇关于可以使用Xml文件作为数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆