优化mysql表?

发布于 2024-08-29 20:49:40 字数 1076 浏览 5 评论 0原文

这是我的实际表架构(我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不…忘初心 2024-09-05 20:49:40

我不确定您正在寻找哪种优化,但这绝对应该标准化为定义实验样本和实验 rna 关系的表,例如像这样:

experiments_to_samples
id  |  experiment_id | sample_id |  


experiments_to_rnas
id  |  experiment_id | rna_id |

这样,每个实验都可以拥有无限数量的samplerna 参考文献。

假设有一个表 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:

experiments_to_samples
id  |  experiment_id | sample_id |  


experiments_to_rnas
id  |  experiment_id | rna_id |

that way, every experiment can have an unlimited number of sample and rna references.

This is assuming that there is a table samples and a table rna.

装迷糊 2024-09-05 20:49:40

像这样标准化你的表:

Table experiment :
code(int)
experiment_start

Table sample:
sample_id
code   fk to experiment.code


table rna:
rna_id
code   fk to experiment.code

normalize your tables like this:

Table experiment :
code(int)
experiment_start

Table sample:
sample_id
code   fk to experiment.code


table rna:
rna_id
code   fk to experiment.code
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文