如何使用文本分隔文件填充Postgresql数据库

时间:2019-06-25 12:36:21

标签: mysql postgresql

很抱歉,这个问题很天真,但是对于这个数据库世界我还是一个新手,我有两个制表符分隔的文件,我想用它们来填充数据库。但是,我不知道如何使用foreignprimary键来将一个表链接到另一个表。

我的表是这样创建的:

/*A table for Variants*/
CREATE TABLE variants (
    varid serial PRIMARY KEY,
    chrom VARCHAR(50),
    pos VARCHAR(50),
    id VARCHAR(10) DEFAULT '-',
    ref VARCHAR(1000),
    alt VARCHAR(1000),
    compid VARCHAR(1000),
    targeted_allele_freq decimal,
    targeted_freq_factors VARCHAR(1000),
    exome_allele_freq decimal,
    exome_freq_factors VARCHAR(1000),
    rna_allele_freq decimal,
    rna_freq_factors VARCHAR(1000)
);

 /*A table for Annotations associated to a given variant*/
CREATE TABLE annotations (
    varid int not null,
     gene_refgene VARCHAR(10000) DEFAULT '-',
    func_refgene VARCHAR(10000) DEFAULT '-',
    refgene_transcript VARCHAR(10000) DEFAULT '-',/*Transcript from RefSeq*/
    refgene_exon VARCHAR(10000) DEFAULT '-',/*Exon*/
    refgene_nt_change  VARCHAR(10000) DEFAULT '-',/*nucleotidic change*/
    refgene_aa_change VARCHAR(10000) DEFAULT '-',/*Brings all the aminoacids changes*/
    gene_gencode VARCHAR(10000) DEFAULT '-',    
    func_gencode VARCHAR(10000) DEFAULT '-',
    gencode_transcript VARCHAR(10000) DEFAULT '-',/*Transcript from RefSeq*/
    gencode_exon VARCHAR(10000) DEFAULT '-',/*Exon*/
    gencode_nt_change  VARCHAR(10000) DEFAULT '-',/*nucleotidic change*/
    gencode_aa_change VARCHAR(10000) DEFAULT '-',/*Brings all the aminoacids changes*/
    polyphen2_hdiv_pred VARCHAR(100) DEFAULT '-',
    polyphen2_hvar_pred VARCHAR(100) DEFAULT '-',
    mutationtaster_pred VARCHAR(100) DEFAULT '-',
    mutationassessor_pred VARCHAR(100) DEFAULT '-',
    lrt_pred VARCHAR(100) DEFAULT '-',
    provean_pred VARCHAR(100) DEFAULT '-',
    fathmm_pred VARCHAR(100) DEFAULT '-',
    sift_pred VARCHAR(100) DEFAULT '-',
    fathmm_mkl_coding_pred VARCHAR(100) DEFAULT '-',
    metasvm_pred VARCHAR(100) DEFAULT '-',
    metalr_pred VARCHAR(100) DEFAULT '-',
    FOREIGN KEY(varid) REFERENCES variants(varid)
);

我知道在使用mysql时可以使用命令LOAD从文本文件填充数据库,但是我的问题是了解这种方案的工作原理。在以制表符分隔的文件中,用于填充annotations表的文件需要具有一个varidvarid表中的variants匹配的varid如果我的注释文件没有与此匹配的variants,在这两个表之间创建链接?

在我的数据库中,chromposannotations结合时是唯一的,如果我在variants中创建另一列以匹配@Override public ExampleviewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.example_item,parent, false); ExampleviewHolder evh = new ExampleviewHolder(v); return evh; } 上的某些列文件?

谢谢

0 个答案:

没有答案