如何在SQL数据库中组织10.000s不同大小的表 [英] How to organize 10.000s of tables of different size in a SQL database

查看:52
本文介绍了如何在SQL数据库中组织10.000s不同大小的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,用户可以在其中将数据填充到表中。桌子的大小各不相同,有些是3x2,有些是30x20。
就像excel工作表一样,用户可以根据需要添加行和列。这些是与产品相关的图表,因此每个表都有唯一的产品编号

I have a program where the user fills data into a table. The tables all have different sizes, some are 3x2, others are 30x20. Its just like an excel sheet and looks like this, where the user can add rows and columns as much as she needs them. These are charts related to products so each table has a unique product number

在SQL数据库中组织此数据的最佳方法是什么?
每个用户生成的表都是一个SQL表吗?

Whats the best way to organize this data in a SQL database? Is it one SQL table per user generated table?

这似乎过多,因为我最终将拥有一个具有10000个表的数据库。还有其他更好的方法来存储数据吗?我可以将它组合成一个SQL表吗?

This seems excessive as i would end up with a database with 10000s of tables. Are there other, better ways to store the data? Can i combine it into one SQL table?

推荐答案

您可以使SQL表成为

table_header
- id
- rows
- cols

table_detail
- header_id
- row
- col
- value

然后存储表格您创建一个标题记录并一次添加一个条目的内容。要读回表,您基本上只需提取表的所有数据,如果想使解析回表更容易,可以使用 ORDER BY 。像这样。

Then to store a table you create a header record and add the contents one entry at a time. To read the table back you would basically just pull all data for the table, maybe with an ORDER BY if you want to make parsing back into the table easier. Something like that.

这篇关于如何在SQL数据库中组织10.000s不同大小的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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