简体   繁体   English

关系数据库不适合我的应用程序 - 有什么替代方案?

[英]Relational databases are not suited for my application - what's the alternative?

I'm writing a CMS in PHP that allows the user to define different fields (eg a Blog page could have fields for Title (string), Content (rich text), Picture (file)). 我正在用PHP编写CMS,允许用户定义不同的字段(例如,博客页面可以包含标题(字符串),内容(富文本),图片(文件))字段。 I need the user to be able to add and remove fields dynamically, and the only way I can think of to do it with relational DBs is to serialise all these values and store them in one cell. 我需要用户能够动态添加和删除字段,我能想到的关系数据库的唯一方法是序列化所有这些值并将它们存储在一个单元格中。

This seems like a slow approach and like I'm trying to fit something dynamic within a static structure. 这似乎是一种缓慢的方法,就像我试图在静态结构中拟合动态一样。 Could someone recommend anything that is PHP-compatible that would make this easier? 有人可以推荐任何兼容PHP的东西,这会让这更容易吗?

One answer is document-oriented databases such as CouchDB. 一个答案是面向文档的数据库 ,如CouchDB。

Another answer is not to have a pre-defined database, but create it dynamically in response to user's wishes. 另一个答案是没有预先定义的数据库,而是动态创建它以响应用户的意愿。

Third possibility, within a relational database, is to have a table that looks like (id, name, value) , so that a n-column row would be written as n rows in this table. 在关系数据库中,第三种可能性是具有一个看起来像(id, name, value) ,以便在该表中将n列行写为n行。 It's not too pretty though. 虽然它不是太漂亮。 It is easy enough to find any specific value then, but if you want them all you will want a n-fold custom-built join :) 然后很容易找到任何具体的值,但如果你想要它们,你将需要一个n倍的定制连接:)

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

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