MySQL: 帮助设计用于存储可变数量的相同表单列表的表
MySQL: help designing tables for storing variable numbers of identical form lists
我正在摄取 JSON 客户表单的转储,该表单本身包含来自子表单的数据。所以我有像 'username' 这样的数据字段,然后是可能包含也可能不包含数据的表单数据块。与我有关的部分如下所示:
"instruction1"=>true,
"instructionID1"=>1234,
"instructionInfo1"=>"blah blah",
"instructionReqs1"=>"bleh bleh",
"instructionDue1"=>1970-01-01,
...
这部分再重复 14 次(eg. 'instruction2'=>false, &c)
。每个块要么有内容,要么没有,但每条记录总共有 15 条作为要存储的总记录的 部分 。我不知道如何最好地存储它。现在,当我尝试添加第 15 个块时,试图只是用钝力创伤这个东西给了我这个错误:
Failed to add recordRow size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
并且因为我不想将整个东西(以及其他所有东西)克隆到 MariaDB 的新实例(除非它绝对是解决这个问题的唯一方法),innodb_page_size=64k
修复是可行。
我忍不住盯着这个说 "this chunk should be a table",但如果我为它做了一个 table,它的结构将如何只存储信息,而不是空字段(例如. 'instruction1xxx' 到 'instruction6xxx' 之外什么都没有,因为它们是空的),然后以我可以将其全部检索到仪表板的方式将其引用回父记录。
*怒* *噗* *喘*
我仔细阅读了其他对模糊相似问题的回答,MongoDB 在这里不是一个选项,因为其余的生产堆栈集成。
我希望这是有道理的,并且我可以对此有一些清晰的了解。如果您需要更多说明,请告诉我。
TIA。
使用简单的键值table。
CREATE TABLE formdata (
client_id INT(11), // foreign key to client table
name VARCHAR(128),
value VARCHAR(1024)
);
然后 JSON 中的每个项目将成为 table 中的一行。
client_id name value
1 instruction1 true
1 instructionID1 1234
1 instructionInfo1 blah blah
...
我正在摄取 JSON 客户表单的转储,该表单本身包含来自子表单的数据。所以我有像 'username' 这样的数据字段,然后是可能包含也可能不包含数据的表单数据块。与我有关的部分如下所示:
"instruction1"=>true,
"instructionID1"=>1234,
"instructionInfo1"=>"blah blah",
"instructionReqs1"=>"bleh bleh",
"instructionDue1"=>1970-01-01,
...
这部分再重复 14 次(eg. 'instruction2'=>false, &c)
。每个块要么有内容,要么没有,但每条记录总共有 15 条作为要存储的总记录的 部分 。我不知道如何最好地存储它。现在,当我尝试添加第 15 个块时,试图只是用钝力创伤这个东西给了我这个错误:
Failed to add recordRow size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs
并且因为我不想将整个东西(以及其他所有东西)克隆到 MariaDB 的新实例(除非它绝对是解决这个问题的唯一方法),innodb_page_size=64k
修复是可行。
我忍不住盯着这个说 "this chunk should be a table",但如果我为它做了一个 table,它的结构将如何只存储信息,而不是空字段(例如. 'instruction1xxx' 到 'instruction6xxx' 之外什么都没有,因为它们是空的),然后以我可以将其全部检索到仪表板的方式将其引用回父记录。
*怒* *噗* *喘*
我仔细阅读了其他对模糊相似问题的回答,MongoDB 在这里不是一个选项,因为其余的生产堆栈集成。
我希望这是有道理的,并且我可以对此有一些清晰的了解。如果您需要更多说明,请告诉我。
TIA。
使用简单的键值table。
CREATE TABLE formdata (
client_id INT(11), // foreign key to client table
name VARCHAR(128),
value VARCHAR(1024)
);
然后 JSON 中的每个项目将成为 table 中的一行。
client_id name value
1 instruction1 true
1 instructionID1 1234
1 instructionInfo1 blah blah
...