CREATE TABLE master_app_production.table_rels (
  id INT(11) AUTO_INCREMENT PRIMARY KEY,
  order_type_code SMALLINT(6) COMMENT "受注／発注区分",
  table_name VARCHAR(80) COMMENT "テーブル名",
  disp_sort SMALLINT(6) COMMENT "関連順",
  trans_type_code SMALLINT(6) COMMENT "関連先の取引区分",
  sign_type_code SMALLINT(6) COMMENT "赤/黒",
  j_table_name VARCHAR(80) COMMENT "テーブル名(ja)",
  invalid_flag_code SMALLINT(6) COMMENT "有効/無効",
  created_at DATETIME COMMENT "作成日時",
  updated_at DATETIME COMMENT "更新日時"
) type=InnoDB;

INSERT INTO master_app_production.table_rels SET order_type_code=1,table_name="orders",trans_type_code=1,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=1,table_name="shippings",trans_type_code=1,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=2,table_name="orders",trans_type_code=2,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=2,table_name="shippings",trans_type_code=2,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=3,table_name="orders",trans_type_code=3,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=3,table_name="shippings",trans_type_code=3,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=4,table_name="orders",trans_type_code=4,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=4,table_name="shippings",trans_type_code=4,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#売上報告
INSERT INTO master_app_production.table_rels SET order_type_code=5,table_name="orders",trans_type_code=5,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=5,table_name="purchases",trans_type_code=1,disp_sort=2,j_table_name="仕入処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=5,table_name="sales",trans_type_code=1,disp_sort=3,j_table_name="売上処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#売上補充
INSERT INTO master_app_production.table_rels SET order_type_code=6,table_name="orders",trans_type_code=6,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=6,table_name="shippings",trans_type_code=5,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=6,table_name="purchases",trans_type_code=1,disp_sort=3,j_table_name="仕入処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=6,table_name="sales",trans_type_code=1,disp_sort=4,j_table_name="売上処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#サンプル報告
INSERT INTO master_app_production.table_rels SET order_type_code=7,table_name="orders",trans_type_code=7,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=7,table_name="samples",trans_type_code=NULL,disp_sort=2,j_table_name="サンプル処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#サンプル補充
INSERT INTO master_app_production.table_rels SET order_type_code=8,table_name="orders",trans_type_code=8,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=8,table_name="shippings",trans_type_code=6,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=8,table_name="samples",trans_type_code=NULL,disp_sort=3,j_table_name="サンプル処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#注文買取
INSERT INTO master_app_production.table_rels SET order_type_code=9,table_name="orders",trans_type_code=9,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=9,table_name="shippings",trans_type_code=7,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=9,table_name="purchases",trans_type_code=2,disp_sort=3,j_table_name="仕入処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=9,table_name="sales",trans_type_code=2,disp_sort=4,j_table_name="売上処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#貸出買取
INSERT INTO master_app_production.table_rels SET order_type_code=10,table_name="orders",trans_type_code=10,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=10,table_name="purchases",trans_type_code=3,disp_sort=2,j_table_name="仕入処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=10,table_name="sales",trans_type_code=3,disp_sort=3,j_table_name="売上処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#交換依頼
INSERT INTO master_app_production.table_rels SET order_type_code=11,table_name="orders",trans_type_code=11,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=11,table_name="shippings",trans_type_code=8,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=11,table_name="restorations",trans_type_code=2,disp_sort=3,j_table_name="返却処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#在庫移動
INSERT INTO master_app_production.table_rels SET order_type_code=12,table_name="orders",trans_type_code=12,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=12,table_name="restorations",trans_type_code=3,disp_sort=2,j_table_name="返却処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=12,table_name="shippings",trans_type_code=9,disp_sort=3,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#返却のみ
INSERT INTO master_app_production.table_rels SET order_type_code=13,table_name="orders",trans_type_code=13,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=13,table_name="restorations",trans_type_code=1,disp_sort=2,j_table_name="返却処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#倉庫間移動(有効期限延長)
INSERT INTO master_app_production.table_rels SET order_type_code=14,table_name="purchases",trans_type_code=5,disp_sort=1,j_table_name="仕入処理(倉庫間移動出庫)",sign_type_code=0, created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=14,table_name="purchases",trans_type_code=7,disp_sort=2,j_table_name="仕入処理(倉庫間移動入庫)",sign_type_code=1, created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#預り入庫
INSERT INTO master_app_production.table_rels SET order_type_code=15,table_name="purchases",trans_type_code=6,disp_sort=1,j_table_name="仕入処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#サンプル注文
INSERT INTO master_app_production.table_rels SET order_type_code=16,table_name="orders",trans_type_code=16,disp_sort=1,j_table_name="発注処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=16,table_name="shippings",trans_type_code=10,disp_sort=2,j_table_name="出荷処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
INSERT INTO master_app_production.table_rels SET order_type_code=16,table_name="samples",trans_type_code=NULL,disp_sort=3,j_table_name="サンプル処理", created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#加工出庫
INSERT INTO master_app_production.table_rels SET order_type_code=17,table_name="purchases",trans_type_code=8,disp_sort=1,j_table_name="仕入処理(加工出庫)", sign_type_code=0, created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;
#加工入庫
INSERT INTO master_app_production.table_rels SET order_type_code=18,table_name="purchases",trans_type_code=9,disp_sort=1,j_table_name="仕入処理(加工入庫)", sign_type_code=1, created_at=NOW(), updated_at=NOW(), invalid_flag_code=0;




