为未知数量的字段创建一个表

时间:2014-04-22 01:35:58

标签: mysql performance

我有一个这样的表格:

选项1 - 值1(数字)

选项2 - 值2(数字)

...

选项459 - 值459(数字)

“添加新选项”

如你所见,我不知道会有多少选择。我只知道如果通过url访问一个选项,我需要在每次访问的时候在某个地方设置+ 1。

我的桌子应该怎么样?

1 个答案:

答案 0 :(得分:0)

你可能想要一个长而窄的"表:

CREATE TABLE OptionValue (
 id INT --this is a surrogate primary key. Optional, but I like to have them.
,optionGroup INT --since you have more then one set of options stored here
,optionNo INT,
,Value numeric
)

或类似的东西。

相关问题