用于存储动态数据的数据结构
我想存储本质上是动态的数据。用户可以创建用于捕获数据的表单。数据可以根据配置以各种格式存储。主要的是 RDBMS 和 XML 文件。 XML 文件格式非常容易存储动态数据并将其加载回来。
我无法为 RDBMS 设计数据结构。我目前以键值格式存储数据,并执行 PIVOT 来获取它。对于具有多个值的字段,我将它们以 CSV 形式存储在值列中。
是否有更好的方法来存储此类有助于提高性能和可扩展性的动态数据?
I want to store data which is dynamic in nature. The user can create forms for capturing data. The data can be stored in various formats as per the configuration. The major ones are a RDBMS and a XML file. XML file format is pretty easy to store dynamic data and load it back.
I am not able to devise a data structure for a RDBMS. I currently store data in a key-value format and do a PIVOT for fetching it. For fields which have multiple values I store them as CSV in the value column.
Is there a better way for storing such dynamic data which helps in performance and extensibility?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不了解更多有关您的应用程序的信息,就很难说。
您可以将数据以 XML 形式保存在数据库中的 BLOB 中。这意味着您的所有数据(某种程度上)都以相同的方式(如 XML)处理。
另一种方法是更改数据库结构以保存嵌套数据(这似乎是您的问题)。因此,您可能拥有一个可以引用自身的表结构(例如父 - 键 - 值),并且有一个标头表来保存顶级键,而不是直接的键值表。
但真正的问题是为什么要使用数据库来保存数据。看来真正的问题是试图将圆钉装入方孔(反之亦然)。
Without knowing more about your application it is hard to say.
You could save the data as XML in a BLOB in the database. That would mean all your data was (sorta) handled the same way (as XML).
The other approach would be to change your database structure to hold nested data (which appears to be your problem). So instead of a straight key-value table you might hace a table structure that could reference itself (e.g. parent - key - value) and have a header table to hold the top level keys.
The real question though is why you want to use a database to hold the data. It seems the real problem is trying to fit a round peg into a square hole (or vice versa).