では、DataCoordinatorを使用して、商用データベースを「Oracle Database 10g Release 10.2.0.1.0」、オープンソースを「PostgreSQL 8.1.5」と想定したデータを連携する方法を解説します。
商用データベース側では以下のように表を準備します。
create table master_table
(goods_code char(6) primary key,
goods_name char(7),
price integer);
オープンソースのデータベース側では、以下のように作業を行います。
create table low_price_table
(goods_code char(6) primary key,
goods_name char(7),
price integer);
create table high_price_table
(goods_code char(6) primary key,
goods_name char(7),
price integer);
テストに使用するデータは、商用データベースのみに挿入しておきます。
insert into master_table values ('A-7001',’goods_a’,100,000);
insert into master_table values ('B-3001',’goods_x’,37,000);
insert into master_table values ('A-8001',’goods_g’,280,000);
insert into master_table values ('A-7002',’goods_b’,120,000);
insert into master_table values ('B-3003',’goods_y’,25,000);
今回のデータ連携では、master_tableからlow_price_table、high_price_tableへデータを送ります。その際、low_price_tableへは価格が10万円未満の商品だけ、high_price_tableへは価格が10万円以上の商品だけを送ります。
上記のデータをそれぞれのデータベースに送った場合、以下のように振り分けられることになります。
low_price_table
‘B-3001’,’goods_x’,37,000
‘B-3003’,’goods_y’,25,000
high_price_table
‘A-7001’,’goods_a’,100,000
‘A-8001’,’goods_g’,280,000
‘A-7002’,’goods_b’,120,000
なお文中で、データを抽出する元になる表(今回の例では、master_table)を「マスタ表」、データを反映する先の表(今回の例では、low_price_tableとhigh_price_table)を、それぞれ「レプリカ表」と呼びます。
DataCoordinatorでデータ連携定義を作成する場合、あらかじめ反映する先となるレプリカ表を登録しておく必要があります。
|