动态表生成 [英] Dynamic Table Generation

查看:119
本文介绍了动态表生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我描述我的情况,以便你能够更好的帮助我。有两个部分。



1:
我有一个运行和分析一堆文件的程序。它会生成一个报告,后来将被送入一个网站进行数据库存储和查看。该报告可以包含几乎任何类型的数据,因为用户几乎可以查询任何内容。我离开它非常开放。



2:
网站通过此报告进行解析,为常见的事情添加了条目。但是也可以为它找到的任何新数据创建一个新表。它还存储从report_id到所有这些动态创建的表的映射。例如,如果在报告中有人想要计算标准偏差,这对本报告来说是有道理的,而不是STD表。



现在这个网站是写的在PHP中,看起来有点混乱。有没有更好的方法来做这个PHP。另外,我正在考虑在Rails中修改这个,因为组织的缘故。有没有更好的方法在rails,method_missing?。



我不是很熟练的建立网站,业余的DB,所以请善待。 >

感谢
Eric

解决方案

看起来你有非结构化,或最多半结构化数据。经典的关系数据库表不是理想的,除非你使用XML作为存储。您可以考虑使用中间


First let me describe my situation so that you might be able to help me better. There are two parts.

1: I have a program that runs and analyzes a bunch of files. It generates a "report" that will later be fed into a website for DB storage and viewing. This report can contain pretty much any type of data, as the users can query pretty much anything. I left it very open ended.

2: The website parses through this report, adds an entry for things that are common. But also creates a new table for any new data it finds. It also stores a mapping from report_id to all of these dynamically created tables. For example if in the report someone wanted to calculate Standard Deviation, and this made sense for this report, than there would be a STD table.

Right now this site is written in PHP, and looks kind of messy. Is there a better way to do this PHP. Also, I'm considering reworking this in Rails because organization sake. Is there a better way in rails, "method_missing?".

I am not very skilled at building websites, and amateurish at DB, so please be kind.

Thanks Eric

解决方案

Looks like that you have unstructured, or at best semi-structured data. Classic relational DB tables are not ideal for this, unless you use XML as storage. You may consider coming up with an intermediate report-definition language and then storing that in a DB, usually as XML. MS SQL server, Oracle, and DB2 support storage and query of XML data.

After some thinking..
You could also look into the observation pattern and see if you could adapt it to this example. Although the pattern is OO, it can be done in SQL.
It is a bit long explanation, but I have published a simplified model here; hope you find this useful.

这篇关于动态表生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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