我有很多类似以下表格的表格。
main_table
id |customer_id | tabl2_id | tabl1_subJson_id |...
---|------------|-----------|------------------|------
1 | 1 | 1 | 2 |...
2 | 1 | 2 | 0 |...
3 | 2 | 3 | 1 |...
4 | 3 | 3 | 3 |...
tabl1
id |customer_id(unique) | json_column1 |
---|--------------------|------------------------------------------------------|
1 | 1 | {"1":['a','b','c'],"2":['e'],"3":['f','g']} |
2 | 2 | {"1":['h','i'],"2":['j',,'k'],"3":['l','m']} |
3 | 3 | {"1":['n','o','p'],"2":['q'],"3":['r','s','t','v']} |
table2
id | name | ...
---|----------|-----
1 | myName1 | ...
2 | myName2 | ...
3 | myName3 | ...
我需要如下表所示的输出 结果
id |customer | tabl2_name| tabl1_subJson |...
---|----------|-----------|------------------|------
1 | jack | myName1 | c |...
2 | jack | myName2 | e |...
3 | lisa | myName3 | k |...
4 | karl | myName3 | v |...
我还有其他问题: 像tabl1之类的表更好,还是诸如以下表之类的表?
tabl_a
id | name | sub_name | ...
---|----------|----------------------|------
1 | myName1 | ['a','b','c'] | ...
2 | myName2 | ['e'] | ...
3 | myName3 | ['f','g'] | ...
...| .... | ... | ...
12 | myName2 | ['mm','dn'] | ...
或 table_b
id | name | sub_name | ...
---|----------|----------|------
1 | myName1 | a | ...
2 | myName1 | b | ...
3 | myName1 | c | ...
...| .... | ... | ...
12 | myName2 | mm | ...
如果有100万用户,则表中的记录数将如下:
tabl1 = 1,000,000
如果名称列具有12个常量名称: tabl_a = 12,000,000
如果每个用户平均拥有20个子名称: tabl_b = 240,000,000