The Exchange Projectでは、ひとつのカタログ・データベースに設定、商品、顧客、注文などの情報を記録します。
データベース名は、以下のファイルの中で設定されます。
これらのファイルの中では、次のように、RDBMSが稼動しているホスト名と、使用するデータベース名を指定します。
define('DB_SERVER', 'exchange'); define('DB_DATABASE', 'catalog');
データベースの構造は、パッケージ中のmysql_catalog.sqlで定義されています。
カタログ・データベースの中には、以下のテーブルがふくまれます。
顧客が作成するアドレス帳の情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
address_book_id | int(5) | 必須 | ○ | 主 | アドレス帳ID |
entry_gender | char(1) | 必須 | 性別 | ||
entry_firstname | varchar(32) | 必須 | 名 | ||
entry_lastname | varchar(32) | 必須 | 姓 | ||
entry_street_address | varchar(64) | 必須 | 住所1 | ||
entry_suburb | varchar(32) | 住所2 | |||
entry_postcode | varchar(10) | 必須 | 郵便番号 | ||
entry_city | varchar(32) | 必須 | 市区町村名 | ||
entry_state | varchar(32) | 都道府県名 | |||
entry_country_id | int(5) | 必須 | 国ID | ||
entry_zone_id | int(5) | 必須 | 都道府県ID |
address_book_idの参照元: 表[address_book_to_customers テーブル]
顧客とアドレス帳を結びつけるための情報を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
address_book_to_customers_id | int(5) | 必須 | ○ | 主 | 顧客−アドレス帳リンクID |
address_book_id | int(5) | 必須 | アドレス帳ID | ||
customers_id | int(5) | 必須 | 顧客ID |
address_book_to_customers_idの参照元:なし
住所フォーマットを記録します。住所フォーマットは、住所を表記するときに、どんな項目をどんな順番でならべるかを定義した規則です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
address_format_id | int(5) | 必須 | ○ | 主 | 住所フォーマットID |
address_format | varchar(128) | 必須 | 住所フォーマット | ||
address_summary | varchar(48) | 必須 | 短縮住所フォーマット |
address_format_idの参照元: 表[countries テーブル], 表[orders テーブル]
カテゴリーのマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
categories_id | int(5) | 必須 | ○ | 主 | カテゴリーID |
categories_name | varchar(32) | 必須 | 副 | カテゴリー名 | |
categories_image | varchar(64) | カテゴリー画像 | |||
parent_id | int(5) | 親ID | |||
sort_order | int(3) | 整列順 |
categories_idの参照元: 表[products_to_categories テーブル]
設定グループに属する設定項目と設定値を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
configuration_id | int(5) | 必須 | ○ | 主 | 設定ID |
configuration_title | varchar(64) | 必須 | 設定タイトル | ||
configuration_key | varchar(64) | 必須 | 設定キー | ||
configuration_value | varchar(255) | 必須 | 設定値 | ||
configuration_description | varchar(255) | 必須 | 設定説明 | ||
configuration_group_id | int(5) | 必須 | 設定グループID | ||
sort_order | int(5) | 整列順 | |||
last_modified | timestamp(14) | 更新日 | |||
date_added | timestamp(14) | 必須 | 追加日 | ||
use_function | varchar(32) | 関数名 |
configuration_idの参照元:なし
設定グループのマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
configuration_group_id | int(5) | 必須 | ○ | 主 | 設定グループID |
configuration_group_title | varchar(64) | 必須 | 設定グループ・タイトル | ||
configuration_group_description | varchar(255) | 必須 | 設定グループ説明 | ||
sort_order | int(5) | 整列順 |
configuration_group_idの参照元: 表[configuration テーブル]
ショップへのアクセス数を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
startdate | char(8) | 開始日('yyyymmdd'形式) | |||
counter | int(12) | アクセス数 |
未使用。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
month | char(8) | ||||
counter | int(12) |
国のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
countries_id | int(5) | 必須 | ○ | 主 | 国ID |
countries_name | varchar(64) | 必須 | 副 | 国名 | |
countries_iso_code_2 | char(2) | 必須 | ISOコード(2桁) | ||
countries_iso_code_3 | char(3) | 必須 | ISOコード(3桁) | ||
address_format_id | int(5) | 必須 | 住所フォーマットID |
countries_idの参照元: 表[address_book テーブル], 表[customers テーブル], 表[zones テーブル]
通貨のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
currencies_id | int(5) | 必須 | ○ | 主 | 通貨ID |
title | varchar(32) | 必須 | 通貨名 | ||
code | char(3) | 必須 | 通貨コード | ||
symbol_left | varchar(12) | 金額の左側文字列 | |||
symbol_right | varchar(12) | 金額の右側文字列 | |||
decimal_point | char(1) | 小数点の文字 | |||
thousands_point | char(1) | 3桁区切り文字 | |||
decimal_places | char(1) | 小数点以下の桁数 |
currencies_idの参照元:なし
顧客の個人情報を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
customers_id | int(5) | 必須 | ○ | 主 | 顧客ID |
customers_gender | char(1) | 必須 | 性別 | ||
customers_firstname | varchar(32) | 必須 | 名 | ||
customers_lastname | varchar(32) | 必須 | 姓 | ||
customers_dob | varchar(8) | 必須 | 生年月日 | ||
customers_email_address | varchar(96) | 必須 | E-Mailアドレス | ||
customers_street_address | varchar(64) | 必須 | 住所1 | ||
customers_suburb | varchar(32) | 住所2 | |||
customers_postcode | varchar(10) | 必須 | 郵便番号 | ||
customers_city | varchar(32) | 必須 | 市区町村 | ||
customers_state | varchar(32) | 都道府県 | |||
customers_telephone | varchar(32) | 必須 | 電話番号 | ||
customers_fax | varchar(32) | FAX番号 | |||
customers_password | varchar(40) | 必須 | パスワード | ||
customers_country_id | int(5) | 必須 | 国ID | ||
customers_zone_id | int(5) | 必須 | ゾーンID |
customers_idの参照元: 表[address_book_to_customers テーブル], 表[customers_basket テーブル], 表[customers_basket_attributes テーブル], 表[orders テーブル], 表[reviews_extra テーブル]
ショッピング・バスケットの情報です。1レコードが1商品を表します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
customers_basket_id | int(5) | 必須 | ○ | 主 | バスケットID |
customers_id | int(5) | 必須 | 顧客ID | ||
products_id | int(5) | 必須 | 商品ID | ||
customers_basket_quantity | int(2) | 必須 | 数量 | ||
final_price | decimal(6,2) | 必須 | 販売価格 | ||
customers_basket_date_added | char(8) | 追加日 |
customers_basket_idの参照元:なし
ショッピング・バスケットの属性情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
customers_basket_attributes_id | int(5) | 必須 | ○ | 主 | バスケット属性ID |
customers_id | int(5) | 必須 | 顧客ID | ||
products_id | int(5) | 必須 | 商品ID | ||
products_options_id | int(5) | 必須 | 商品オプションID | ||
products_options_value_id | int(5) | 必須 | 商品オプション値ID |
customers_basket_attributes_idの参照元:なし
顧客の管理情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
customers_info_id | int(5) | 必須 | 主 | 顧客情報ID | |
customers_info_date_of_last_logon | char(8) | 最新ログイン日 | |||
customers_info_number_of_logons | int(5) | 通産ログイン回数 | |||
customers_info_date_account_created | char(8) | アカウント作成日 | |||
customers_info_date_account_last_modified | char(8) | アカウント更新日 |
customers_info_idの参照元:なし
言語のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
languages_id | int(5) | 必須 | ○ | 主 | 言語ID |
name | varchar(32) | 必須 | 副 | 言語名 | |
code | char(2) | 必須 | 言語コード | ||
image | varchar(64) | 言語画像 | |||
directory | varchar(32) | ディレクトリ | |||
sort_order | int(3) | 整列順 |
languages_idの参照元:なし
メーカーのマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
manufacturers_id | int(5) | 必須 | ○ | 主 | メーカーID |
manufacturers_name | varchar(32) | 必須 | 副 | メーカー名 | |
manufacturers_image | varchar(64) | メーカー画像 |
manufacturers_idの参照元: 表[products テーブル]
注文の情報を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
orders_id | int(5) | 必須 | ○ | 主 | 注文ID |
customers_id | int(5) | 必須 | 顧客ID | ||
customers_name | varchar(64) | 必須 | 顧客名 | ||
customers_street_address | varchar(64) | 必須 | 顧客住所1 | ||
customers_suburb | varchar(32) | 顧客住所2 | |||
customers_city | varchar(32) | 必須 | 顧客市区町村 | ||
customers_postcode | varchar(10) | 必須 | 顧客郵便番号 | ||
customers_state | varchar(32) | 顧客都道府県 | |||
customers_country | varchar(32) | 必須 | 顧客国 | ||
customers_telephone | varchar(32) | 必須 | 顧客電話番号 | ||
customers_email_address | varchar(96) | 必須 | 顧客郵便番号 | ||
customers_address_format_id | int(5) | 必須 | 顧客住所フォーマットID | ||
delivery_name | varchar(64) | 必須 | 配送先氏名 | ||
delivery_street_address | varchar(64) | 必須 | 配送先住所1 | ||
delivery_suburb | varchar(32) | 配送先住所2 | |||
delivery_city | varchar(32) | 必須 | 配送先 | ||
delivery_postcode | varchar(10) | 必須 | 配送先 | ||
delivery_state | varchar(32) | 配送先市区町村 | |||
delivery_country | varchar(32) | 必須 | 配送先国 | ||
delivery_address_format_id | int(5) | 必須 | 配送先住所フォーマットID | ||
payment_method | varchar(12) | 必須 | 支払い方法 | ||
cc_type | varchar(20) | クレジットカードタイプ | |||
cc_owner | varchar(64) | クレジットカード所有者 | |||
cc_number | varchar(32) | クレジットカード番号 | |||
cc_expires | varchar(4) | クレジットカード有効期限 | |||
last_modified | timestamp(14) | 更新日 | |||
date_purchased | timestamp(14) | 購入日 | |||
shipping_cost | decimal(8,2) | 必須 | 配送コスト | ||
shipping_method | varchar(32) | 配送手段 | |||
orders_status | varchar(10) | 必須 | 注文ステータス | ||
orders_date_finished | timestamp(14) | 注文処理完了日時 | |||
comments | text | コメント | |||
currency | char(3) | 通貨コード | |||
currency_value | decimal(14,6) | 通貨換算率 |
orders_idの参照元: 表[orders_products テーブル], 表[orders_products_attributes テーブル]
注文された商品の情報です。この1レコードが注文されたひとつの商品を表します。1件の'注文ID'に対して、複数件の'注文商品ID'が結びつきます。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
orders_products_id | int(5) | 必須 | ○ | 主 | 注文商品ID |
orders_id | int(5) | 必須 | 注文ID | ||
products_id | int(5) | 必須 | 商品ID | ||
products_name | varchar(64) | 必須 | 商品名 | ||
products_price | decimal(8,2) | 必須 | 商品価格 | ||
final_price | decimal(8,2) | 必須 | 合計価格 | ||
products_tax | decimal(7,4) | 必須 | 税率(%) | ||
products_quantity | int(2) | 必須 | 数量 |
'final_price'には、数量やオプションもふくめた価格が記録されます。
orders_products_idの参照元: 表[orders_products_attributes テーブル]
注文された商品についての属性情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
orders_products_attributes_id | int(5) | 必須 | ○ | 主 | 注文商品属性ID |
orders_id | int(5) | 必須 | 注文ID | ||
orders_products_id | int(5) | 必須 | 注文商品ID | ||
products_options | varchar(32) | 必須 | 商品オプション | ||
products_options_values | varchar(32) | 必須 | 商品オプション値 | ||
options_values_price | decimal(8,2) | 必須 | 商品オプション価格 | ||
price_prefix | char(1) | 必須 | 価格接頭辞(+/-) |
orders_products_attributesの参照元:なし
商品のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_id | int(5) | 必須 | ○ | 主 | 商品ID |
products_name | varchar(32) | 必須 | 副 | 商品名 | |
products_description | text | 商品説明 | |||
products_quantity | int(4) | 必須 | 数量 | ||
products_model | varchar(12) | 商品型番 | |||
products_image | varchar(64) | 商品画像 | |||
products_url | varchar(255) | 商品URL | |||
products_price | decimal(8,2) | 必須 | 価格 | ||
products_date_added | varchar(8) | 追加日 | |||
products_viewed | int(5) | 閲覧数 | |||
products_weight | decimal(5,2) | 必須 | 重量 | ||
products_status | tinyint(1) | 必須 | ステータス | ||
products_tax_class_id | int(5) | 必須 | 税種別ID | ||
manufacturers_id | int(5) | メーカーID |
products_idの参照元: 表[customers_basket テーブル], 表[customers_basket_attributes テーブル], 表[orders_products テーブル], 表[products_attributes テーブル], 表[products_to_categories テーブル], 表[reviews_extra テーブル], 表[specials テーブル]
商品についての属性情報を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_attributes_id | int(5) | 必須 | ○ | 主 | 商品属性ID |
products_id | int(5) | 必須 | 商品ID | ||
options_id | int(5) | 必須 | オプションID | ||
options_values_id | int(5) | 必須 | オプション値ID | ||
options_values_price | decimal(8,2) | 必須 | オプション値価格 | ||
price_prefix | char(1) | 必須 | 価格接頭辞(+/-) |
products_attributes_idの参照元:なし('orders_products_attributes'に直接オプション名やオプション値価格が記録されます。)
入荷予定商品の情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_expected_id | int(5) | 必須 | ○ | 主 | 入荷予定商品ID |
products_name | varchar(255) | 必須 | 商品名 | ||
date_expected | varchar(8) | 入荷予定日 |
products_expected_idの参照元:なし
商品オプションの定義情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_options_id | int(5) | 必須 | ○ | 主 | 商品オプションID |
products_options_name | varchar(32) | 必須 | 商品オプション名 |
products_options_idの参照元: 表[customers_basket_attributes テーブル], 表[orders_products_attributes テーブル], 表[products_attributes テーブル]
商品オプションの値を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_options_values_id | int(5) | 必須 | ○ | 主 | 商品オプション値ID |
products_options_values_name | varchar(64) | 必須 | 商品オプション値名 |
products_options_values_idの参照元: 表[customers_basket_attributes テーブル], 表[orders_products_attributes テーブル] 表[products_attributes テーブル]
表[products_options テーブル]に記録された商品オプションと、表[products_options_values テーブル]に記録された商品オプション値の対応関係を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_options_values_to_products_options_id | int(5) | 必須 | ○ | 主 | |
products_options_id | int(5) | 必須 | 商品オプションID | ||
products_options_values_id | int(5) | 必須 | 商品オプション値ID |
products_options_values_to_products_optionsの参照元:なし
商品とカテゴリーを結びつける情報を記録します。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
products_id | int(5) | 必須 | ○ | 主 | 商品ID |
categories_id | int(5) | 必須 | カテゴリーID |
products_idの参照元: 表[products テーブル]
レビューの情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
reviews_id | int(5) | 必須 | ○ | 主 | レビューID |
reviews_text | text | 必須 | レビュー文 | ||
reviews_rating | int(1) | 点数 |
reviews_idの参照元: 表[reviews_extra テーブル]
レビューについての追加情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
reviews_id | int(5) | 必須 | レビューID | ||
products_id | int(5) | 必須 | 商品ID | ||
customers_id | int(5) | 必須 | 顧客ID | ||
date_added | char(8) | 必須 | 追加日 | ||
reviews_read | int(5) | 閲覧数 |
特価商品の情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
specials_id | int(5) | 必須 | ○ | 主 | 特価商品ID |
products_id | int(5) | 必須 | 商品ID | ||
specials_new_products_price | decimal(8,2) | 必須 | 特価 | ||
specials_date_added | char(8) | 追加日 |
specials_idの参照元:なし
税種別のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
tax_class_id | int(5) | 必須 | ○ | 主 | 税種別ID |
tax_class_title | varchar(32) | 必須 | 税種別タイトル | ||
tax_class_description | varchar(255) | 必須 | 説明 | ||
last_modified | timestamp(14) | 更新日 | |||
date_added | timestamp(14) | 必須 | 追加日 |
tax_class_idの参照元: 表[products テーブル], 表[tax_rates テーブル]
税率の情報です。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
tax_rates_id | int(5) | 必須 | ○ | 主 | 税率ID |
tax_zone_id | int(5) | 必須 | ゾーンID | ||
tax_class_id | int(5) | 必須 | 税種別ID | ||
tax_rate | decimal(7,4) | 必須 | 税率 | ||
tax_description | varchar(255) | 必須 | 説明 | ||
last_modified | timestamp(14) | 更新日 | |||
date_added | timestamp(14) | 必須 | 追加日 |
tax_rates_idの参照元:なし
都道府県のマスターテーブルです。
カラム名 | 型 | 必須 | 自動採番 | キー | 内容 |
---|---|---|---|---|---|
zone_id | int(5) | 必須 | ○ | 主 | ゾーンID |
zone_country_id | int(5) | 必須 | 国ID | ||
zone_code | varchar(5) | 必須 | ゾーン・コード | ||
zone_name | varchar(32) | 必須 | ゾーン名 |
zone_idの参照元: 表[address_book テーブル], 表[customers テーブル], 表[tax_rates テーブル]
ここでは、パッケージにふくまれるサンプル・データを例にあげて、商品オプションについて説明します。
商品オプションは、以下のテーブルで定義されます。
まず、products_optionsテーブルに、表[(例) products_options]のような'Color' / 'Size' / 'Model' / 'Memory'といった商品オプションの種別を記録しています。
products_options_id | products_options_name |
---|---|
1 | Color |
2 | Size |
3 | Model |
4 | Memory |
次に、products_options_valuesテーブルには、上であげた商品オプションの種別ごとに、具体的な商品オプション値を記録しています。それが表[(例) products_options_values]です。ただ、これではそれぞれの商品オプション値がどの商品オプションに属しているのかが分かりません。
products_options_values_id | products_options_values_name |
---|---|
1 | 4 MB |
2 | 8 MB |
3 | 16 MB |
4 | 32 MB |
5 | Value |
6 | Premium |
7 | Deluxe |
8 | PS/2 |
9 | USB |
その対応関係を記録しているのが、products_options_values_to_products_optionsテーブルです。表[(例) products_options_values_to_products_options]を見ると、1〜4行の'products_options_id'の値'4'に対して、'products_options_values_id'の値が'1'〜'4'となっています。つまり、表[(例) products_options_values]の'4 MB' / '8 MB' / '16 MB' / '32 MB'は、商品オプション'Memory'に属する商品オプション値であるというわけです。同様に、4〜9行の'products_options_id'の値'3'に対して、'products_options_values_id'の値が'5'〜'9'となっていますので、商品オプション'Model'に商品オプション値の'Value' / 'Premium' / 'Deluxe' / 'PS/2' / 'USB'が属していることになります。
products_options_values_to_products_options_id | products_options_id | products_options_values_id |
---|---|---|
1 | 4 | 1 |
2 | 4 | 2 |
3 | 4 | 3 |
4 | 4 | 4 |
5 | 3 | 5 |
6 | 3 | 6 |
7 | 3 | 7 |
8 | 3 | 8 |
9 | 3 | 9 |
これをThe Exchange Projectの管理ページで見ると、図[オプション値]のようになります。
実際の商品では、以上で定義した商品オプション値に価格をつけて、商品属性とします。それを記録するのがproducts_attributesテーブルです。表[(例) products_attributes]を見ると、商品を表す'products_id'に、'options_id'と'options_values_id'で商品オプション値を設定し、'options_values_price'と'price_prefix'で価格を決定しているのが分かります。'price_prefix'が'+'なら、もとの商品価格に対して割増し、'-'なら割引きになります。
products_attributes_id | products_id | options_id | options_values_id | options_values_price | price_prefix |
---|---|---|---|---|---|
1 | 1 | 4 | 1 | 0.00 | + |
2 | 1 | 4 | 2 | 5000.00 | + |
3 | 1 | 4 | 3 | 7000.00 | + |
4 | 1 | 3 | 5 | 0.00 | + |
5 | 1 | 3 | 6 | 10000.00 | + |
6 | 2 | 4 | 3 | 1000.00 | - |
7 | 2 | 4 | 4 | 0.00 | + |
8 | 2 | 3 | 6 | 0.00 | + |
9 | 2 | 3 | 7 | 12000.00 | + |
10 | 26 | 3 | 8 | 0.00 | + |
11 | 26 | 3 | 9 | 600.00 | + |
これをThe Exchange Projectの管理ページで見ると、図[商品属性]のようになります。