如何创建多维数据的创建表? [英] How do I create create table of multidimentional data?

查看:76
本文介绍了如何创建多维数据的创建表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张主表,里面有大约100,000条记录。



表结构是:

------ --------- --------

尺寸|机器|速度|

------ --------- --------

1 M1 100

2 M2 50

3 M3 20

4 M4 60

5 M5 40

.... ...... .....

1000 M100 50



现在,

每台机器的每个尺寸有不同的速度

每台机器在特定尺寸上以不同的速度运行。



如果我继续高于approch那么记录将是1000 * 100 = 100000

不受数据库引擎的限制。



如何设计此表?



我尝试过的事情:



我做这样的事情

尺寸M01 M02 M03 ----- M100

1 100 50 20 30 //速度值



to



1000 100 30 20 ------ 20





但问题出现了我尝试通过参数

解决方案

传递列名来查询如果我理解你的问题和建议(我已经尝试过),请不要将机器名称作为一栏。机器是值,因此它们应存储为行。



想想如果需要新机器会发生什么......你需要改变数据库结构,它很可能也会影响调用程序。



原始结构是什么,如果尺寸和机器定义了速度,那么你当前的桌面结构似乎是有效的。



你写道:

如果我继续上面的approch,那么记录将是1000 * 100 = 100000 
,这不受数据库引擎的限制。



表100'000行不是一张大表。任何现代数据库引擎都应该能够毫无问题地处理这样的行数。



因此,如果数据库确实存在如此少量行的问题,我会考虑更改数据库。否则试一试。


Quote:

如果我继续上面approch那么记录将是1000 * 100 = 100000

不受数据库引擎的限制。



即使在最小的硬件中,SQL服务器处理具有数百万条记录的表也没有问题如果设计是正确的。

您的示例显示唯一值,您不解释表的用途,也不解释用法。

引用:

我该如何设计这个表?



你对这一点没什么建议吗?



引用:

但是当我尝试通过参数传递列名来查询时出现问题



这就是为什么每个人都会告诉你这是一个坏主意的原因,无论表的用法如何。



你需要改进问题


i have one master table which is about 100,000 records in it.

table structure is:
------ --------- --------
size | machine | Speed |
------ --------- --------
1 M1 100
2 M2 50
3 M3 20
4 M4 60
5 M5 40
.... ... .....
1000 M100 50

Now,
Each Size on Every Machine has different speed
Each Machine runs on diffrent speed on perticular size.

If i continue to above approch then records will be 1000*100=100000
which is not tollerated by database engine.

how can i design this table?

What I have tried:

I do Something like this
Size M01 M02 M03 ----- M100
1 100 50 20 30 // speed value

to

1000 100 30 20 ------ 20


but problem occurs when i try to query by passing column name by parameter

解决方案

If I understand your question and suggestion (in what I have tried) correctly, do not put machine name as a column. Machines are values so they should be stored as rows.

Think what happens if a new machine is needed... You would need to change the database structure and it most likely would also affect the calling program.

What comes to the original structure, if the size and machine define the speed then your current table structure seems valid.

You wrote:

If i continue to above approch then records will be 1000*100=100000
which is not tollerated by database engine.


A table 100'000 rows is not a big table. Any modern database engine should be able to handle such amount of rows without any problems.

So if the database really has problems with such small amount of rows I would consider changing the database. Otherwise have a try with it.


Quote:

If i continue to above approch then records will be 1000*100=100000
which is not tollerated by database engine.


An SQL server have no problem handling a table with millions of records even in smallest hardware if design is correct.
Your example show unique value, you don't explain the purpose of the table, nor the usage.

Quote:

how can i design this table?


What advice do you expect with this nothing ?

Quote:

but problem occurs when i try to query by passing column name by parameter


That is the reason why everyone will tell you it is a bad idea, whatever is the usage of the table.

You need to refine the question.


这篇关于如何创建多维数据的创建表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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