将数据从flatfiles加载到MySQL数据库,然后通过外键创建表之间的关系的最快方法是什么?
例如......我有一个平面文件格式:
[INDIVIDUAL] [POP] [MARKER] [GENOTYPE] "INDIVIDUAL1", "CEU", "rs55555","AA" "INDIVIDUAL1", "CEU", "rs535454","GA" "INDIVIDUAL1", "CEU", "rs555566","AT" "INDIVIDUAL1", "CEU", "rs12345","TT" ... "INDIVIDUAL2", "JPT", "rs55555","AT"
我需要加载到四个表中:
IND (id,fk_pop,name) POP (id,population) MARKER (id,rsid) GENOTYPE (id,fk_ind,fk_rsid,call)
具体来说,如何以缩放的方式填充外键?这些数字在1000多个人的范围内,每个人有100万+基因型.
我会采取多步骤的方法来做到这一点.
将数据加载到临时表中,该表与您拥有的文件格式匹配
编写查询以执行其他插入,启动常规表,然后执行连接以获取FK值.