表的结构如下:
basic表
id int primary_key auto_increment
rawId int foreign_key
productId int foreign_keyraw表
rawId int primary_key auto_increment
raw1 float
...
raw1000 floatproduct表
productId int primary_key auto_increment
product1 float
...
product500 float现有两个数据文件(路径为pathRaw, pathProduct),其中关于raw的结构为:(50行*1000列,Tab分隔)
20.1 20.2 32.1 ... 20.1
...
42.1 20.1 42.5 ... 23.1
关于product的结构和关于raw的类似
现要把两个数据文件的数据导入到数据表中,并要求保持三张表的主外键关系,请教各位~  

解决方案 »

  1.   

    现在在某个schema里面建立了basic raw product三张表,有两个数据文件的数据要存入数据表中,文件中的数据包括除主键以外的所有对应数据(主键是自增实现,文件包含多条记录,以回车换行,一条记录一行)。至于测试数据不大好写出,只能像上面那样描述一下。主要是要保持三张表之间的联系。
    如果raw和product的字段比较少,本来可以放在一张表里面的。
    不知道楼上的是否明白。
    表达能力一般,抱歉~
      

  2.   

    这个~我用几个记录和字段表示一下吧~可以的吧
    数据文件pathRaw(数据文件pathProduct暂假定和数据文件pathRaw的内容一样)内容如下:
    20.1 20.2 32.1 20.1
    42.1 20.1 42.5 23.1
    42.1 20.1 42.5 23.1数据存入后要求的结果:
    basic表:
    id rawId productId
    1 11 21
    2 12 22
    3 13 23raw表
    rawId raw1 raw2 raw3 raw4
    11 20.1 20.2 32.1 20.1
    12 42.1 20.1 42.5 23.1
    13 42.1 20.1 42.5 23.1product表
    productId product1 product2 product3 product4
    21 20.1 20.2 32.1 20.1
    22 42.1 20.1 42.5 23.1
    23 42.1 20.1 42.5 23.1
      

  3.   

    3表的ID、rawId、productId之间有关系?
      

  4.   

    不好意思,我检讨~,我再把问题说明一下~
    现有两个数据文件pathRaw和pathProduct,要把数据存入到三张表中(其中一张仅起到连接的作用),因为数据量的原因,现将两个数据表的结构和内容进行简化,简化后内容如下:
    数据文件pathRaw的内容:         数据文件pathProduct的内容:
    20.1 20.2 32.1 20.1             35.4 33.5
    42.1 20.1 42.5 23.1             25.1 39.5
    35.2 51.6 33.4 25.8             44.1 42.5数据存入后要求的结果:
    basic表:                     raw表                            product表
    id rawId productId            rawId raw1 raw2 raw3 raw4        productId product1 product2
    1 11 21                       11 20.1 20.2 32.1 20.1           21 35.4 33.5
    2 12 22                       12 42.1 20.1 42.5 23.1           22 25.1 39.5
    3 13 23                       13 35.2 51.6 33.4 25.8           23 44.1 42.59楼问的id、rawId、productId之间的关系是指数据表建立后,通过数据表查询可以得到如下例的结果:
    1 20.1 20.2 32.1 20.1 35.4 33.5
    2 42.1 20.1 42.5 23.1 25.1 39.5
    3 35.2 51.6 33.4 25.8 44.1 42.5不知道这回我有没有说明白~还请各位海涵
      

  5.   

    各个ID类型是均为自增,我写成1、11、21是为了表示三个表的id不一定相同,也就是说basic表的内容不一定是
    a a a
    b b b
    可能是
    a b c
    d e f
    就是这个意思~
      

  6.   

    这样吧,你还是提供测试文件来说明吧。 (不要高估你的汉语表达能力或者我的汉语理解能力)
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。   
      

  7.   

    /*以下是表的结构*/
    create table raw
    (
    rawId int not null auto_increment,
    raw1 float,
    raw2 float,
    raw3 float,
    raw4 float,
    primary key (rawId) 
    )create table product
    (
    productId int not null auto_increment,
    product1 float,
    product2 float,
    primary key (productId)
    )create table basic
    (
    id int not null auto_increment,
    rawId int ,
    productId int,
    primary key (id),
    foreign key (rawId) references raw(rawId),
    foreign key (productId) references product(productId)
    )/*以下是要存入数据表的数据文件的内容
    文件pathRaw:
    20.1,20.2,32.1,20.1
    42.1,20.1,42.5,23.1
    35.2,51.6,33.4,25.8
    文件pathProduct:
    35.4,33.5
    25.1,39.5
    44.1,42.5
    *//*以下的语句仅仅是为了显示出数据存入以后各个数据表的内容,并非是所要解决问题的方案*/
    /*raw从1开始自增*/
    insert into raw select null,20.1,20.2,32.1,20.1;
    insert into raw select null,42.1,20.1,42.5,23.1;
    insert into raw select null,35.2,51.6,33.4,25.8;

    /*这里故意改变自增的开始数字*/
    insert into product select null,0,0;
    insert into product select null,0,0;
    delete from product;

    /*从3开始自增*/
    insert into product select null,35.4,33.5;
    insert into product select null,25.1,39.5;
    insert into product select null,44.1,42.5;
    /*这里的语句不知道怎么写,所以就直接写出id的数字,按理是通过查询获得要插入的id*/
    insert into basic select null, 1, 3;
    insert into basic select null, 2, 4;
    insert into basic select null, 3, 5;
    所要求助的问题是怎样通过导入pathRaw和pathProduct两个文件,达到以上红色语句执行以后实现的效果。麻烦给出具体一点的代码~
      

  8.   

    ACMAIN_CHM等各位高手,我已经按要求对问题进行了说明,各位给看看吧~
      

  9.   

    楼主,你这个问题解决没?我最近也遇到这个多表导入数据到mysql的问题,想请教一下你~