Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
优化mysql表?_Sql_Mysql_Database Design_Data Structures_Data Modeling - Fatal编程技术网

优化mysql表?

优化mysql表?,sql,mysql,database-design,data-structures,data-modeling,Sql,Mysql,Database Design,Data Structures,Data Modeling,下面是我的实际表模式(我使用的是Mysql): 如何优化这两个部分:sample\n\u id和rna\n\u id(都是bigint(20)并且允许null=true) 关于价值观:我们可以有:例如: 样本_1_id=2, 样本2\u id=5 注意:值可以更新 想法? 谢谢 编辑: 我有三张桌子: Table experiment : sample_1_id .. sample_12_id (not useful with normalization) rna_1_id .. rna_12

下面是我的实际表模式(我使用的是Mysql):

如何优化这两个部分:sample\n\u id和rna\n\u id(都是bigint(20)并且允许null=true)

关于价值观:我们可以有:例如: 样本_1_id=2, 样本2\u id=5

注意:值可以更新

想法? 谢谢


编辑:

我有三张桌子:

Table experiment :
sample_1_id .. sample_12_id (not useful with normalization)
rna_1_id .. rna_12_id (not useful with normalization)


With normalization I should have :

Table Rna :
id
experiment_id
rna_id
rna_name
sample_id (link to a sample in Table sample)

Table Sample :
id
experiment_id
sample_id
sample_name
所以,Rna和样本表之间是有关系的

例如:

Table rna :
    id =1
    experiment_id = 1
    rna_id = rna1
    rna_name = name1
    sample_id = 2

    Table Sample :
    id = 2
    experiment_id = 1
    sample_id = Sample1
    sample_name = SampName

因此,sample_id=2=>表sample:id=2=>sample_id=Sample1

我不确定您在寻找哪种优化,但这肯定应该规范化为定义实验样本和实验rna关系的表,例如:

experiments_to_samples
id  |  experiment_id | sample_id |  


experiments_to_rnas
id  |  experiment_id | rna_id |
这样,每个
实验
都可以有无限数量的
样本
rna
参考


这是假设有一个表
samples
和一个表
rna

将您的表规范化如下:

Table experiment :
code(int)
experiment_start

Table sample:
sample_id
code   fk to experiment.code


table rna:
rna_id
code   fk to experiment.code

我想添加Rna和样本表之间的关系(参见我的编辑)?@fabien你能添加更多关于Rna与样本关系的细节吗?我在上一篇文章中添加了一个示例。
Table experiment :
code(int)
experiment_start

Table sample:
sample_id
code   fk to experiment.code


table rna:
rna_id
code   fk to experiment.code