优化mysql表?
这是我的实际表架构(我正在使用 Mysql):
Table experiment :
code(int)
sample_1_id
sample_2_id
... until ... sample_12_id
rna_1_id
rna_2_id
... until ... rna_12_id
experiment_start
如何优化这两个部分:sample_n_id 和 rna_n_id(全部都是 bigint(20) 并允许 null=true)?
关于价值观:我们可以有:例如: 样本_1_id = 2 , Sample_2_id = 5 , ...
注意:值可以更新。
想法? 谢谢。
编辑:
我有 3 个表:
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 和 Sample 表之间存在关系。
示例:
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 =>在表示例中: id =2 =>样本 ID = 样本 1
Here is my actual table schema (I'm using Mysql) :
Table experiment :
code(int)
sample_1_id
sample_2_id
... until ... sample_12_id
rna_1_id
rna_2_id
... until ... rna_12_id
experiment_start
How can I optimize both part : sample_n_id and rna_n_id (all are bigint(20) and allow null=true) ?
About values : we can have : ex :
sample_1_id = 2 ,
Sample_2_id = 5 , ...
Note : values can be updated.
Ideas ?
Thanks.
Edit :
I have 3 tables :
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
So, there is a relationship between Rna and Sample table.
Example :
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
So, sample_id = 2 => In table sample : id =2 => sample_id = Sample1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您正在寻找哪种优化,但这绝对应该标准化为定义实验样本和实验 rna 关系的表,例如像这样:
这样,每个
实验
都可以拥有无限数量的sample
和rna
参考文献。假设有一个表
samples
和一个表rna
。I'm not sure what kind of optimization you are looking for but this should definitely be normalized into a table defining experiment-sample and experiment-rna relationships, for example like so:
that way, every
experiment
can have an unlimited number ofsample
andrna
references.This is assuming that there is a table
samples
and a tablerna
.像这样标准化你的表:
normalize your tables like this: