引用:
seasoftさんは書きました:
複数列 (規格改訂後の場合、product_id, class_combination_id でしょうか?) でプライマリキー
この件で、少し気になる事があります。
現状、class_combination_idがNULLになるケースがあるという事なので、
購入後に商品を特定するようなケースでは、product_class_id以外に、小細工せずに一意に特定することができなくなるのではないかと思います。
実行SQL:
SELECT
pc.product_code AS product_code,
pc.product_id AS product_id,
pc.product_class_id AS product_class_id,
pc.class_combination_id AS class_combination_id,
cc2.classcategory_id AS classcategory_id1,
cc1.classcategory_id AS classcategory_id2
FROM
dtb_products_class pc LEFT JOIN dtb_class_combination cc1 ON pc.class_combination_id = cc1.class_combination_id
LEFT JOIN dtb_class_combination cc2 ON cc1.parent_class_combination_id = cc2.class_combination_id
結果:
+--------------+------------+------------------+----------------------+-------------------+-------------------+
| product_code | product_id | product_class_id | class_combination_id | classcategory_id1 | classcategory_id2 |
+--------------+------------+------------------+----------------------+-------------------+-------------------+
| ice-01 | 1 | 1 | 10 | 3 | 6 |
| ice-01 | 1 | 2 | 11 | 3 | 5 |
| ice-01 | 1 | 3 | 12 | 3 | 4 |
| ice-01 | 1 | 4 | 13 | 2 | 6 |
| ice-01 | 1 | 5 | 14 | 2 | 5 |
| ice-01 | 1 | 6 | 15 | 2 | 4 |
| ice-01 | 1 | 7 | 16 | 1 | 6 |
| ice-01 | 1 | 8 | 17 | 1 | 5 |
| ice-01 | 1 | 9 | 18 | 1 | 4 |
| nabe-01 | 2 | 10 | NULL | NULL | NULL |
+--------------+------------+------------------+----------------------+-------------------+-------------------+
とはいえ、全体的にproduct_class_idをキーにするのは、かなり大がかりな修正になりそうですしね。
----------------
EC CUORE 株式会社クオーレ
カスタマイズ御相談下さい。