ローカルDB同期概要
説明
ローカルDB同期コンポーネントは、gb_analyzerデータベース内での内部同期操作を担当します。このコンポーネントは、Crawlerによって直接入力される一時ランキングデータ('t_'プレフィックス)を処理し、メインランキングテーブルのクリーンフォーマットに変換します。これにより、商品カテゴリランキングと商品検索クエリランキングが分析とレポート目的で適切に維持・更新されることを保証します。
システム概要図
---
config:
theme: base
layout: dagre
flowchart:
curve: linear
htmlLabels: true
themeVariables:
edgeLabelBackground: "transparent"
---
flowchart TD
Crawler((Crawlerシステム))
SyncCommands[ローカルDB同期コマンド]
subgraph TempTables["gb_analyzer一時テーブル"]
t_category_rankings[(t_category_rankings)]
t_sq_rankings[(t_sq_rankings)]
end
subgraph MainTables["gb_analyzerメインテーブル"]
CategoryRankings[(category_rankings)]
SearchQueryRankings[(search_query_rankings)]
ProductCategoryRankings[(product_category_rankings)]
ProductSearchQueryRankings[(product_search_query_rankings)]
end
Crawler --- CrawlerStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
<p style='margin-top: 8px'>ランキングデータ保存</p>
</div>
]
CrawlerStep --> TempTables
TempTables --- TempTablesStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
<p style='margin-top: 8px'>status=0 未同期を識別</p>
</div>
]
TempTablesStep --> SyncCommands
SyncCommands --- CategoryStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3A</span>
<p style='margin-top: 8px'>カテゴリデータ保存</p>
</div>
]
CategoryStep --> CategoryRankings
SyncCommands --- ProductCategoryStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>3B</span>
<p style='margin-top: 8px'>商品カテゴリランキング保存</p>
</div>
]
ProductCategoryStep --> ProductCategoryRankings
SyncCommands --- SearchQueryStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4A</span>
<p style='margin-top: 8px'>検索クエリデータ保存</p>
</div>
]
SearchQueryStep --> SearchQueryRankings
SyncCommands --- ProductSearchStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #cc66cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>4B</span>
<p style='margin-top: 8px'>商品検索ランキング保存</p>
</div>
]
ProductSearchStep --> ProductSearchQueryRankings
SyncCommands --- StatusUpdateStep[
<div style='text-align: center'>
<span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>5</span>
<p style='margin-top: 8px'>status=1 同期済みにマーク</p>
</div>
]
StatusUpdateStep --> TempTables
style Crawler fill:#fcd9f2,stroke:#ff9900,stroke-width:2px
style SyncCommands fill:#d9f2d9
style TempTables fill:#fcd9f2,stroke:#ff9900,stroke-width:1px
style MainTables fill:#d9d9f2,stroke:#339933,stroke-width:1px
style CategoryRankings fill:#e6f0ff,stroke:#6666cc,stroke-width:1px
style SearchQueryRankings fill:#e6f0ff,stroke:#6666cc,stroke-width:1px
style ProductCategoryRankings fill:#e6f0ff,stroke:#6666cc,stroke-width:1px
style ProductSearchQueryRankings fill:#e6f0ff,stroke:#6666cc,stroke-width:1px
style t_category_rankings fill:#fcd9f2,stroke:#ff6666,stroke-width:1px
style t_sq_rankings fill:#fcd9f2,stroke:#ff6666,stroke-width:1px
style CrawlerStep fill:transparent,stroke:transparent,stroke-width:1px
style TempTablesStep fill:transparent,stroke:transparent,stroke-width:1px
style CategoryStep fill:transparent,stroke:transparent,stroke-width:1px
style ProductCategoryStep fill:transparent,stroke:transparent,stroke-width:1px
style SearchQueryStep fill:transparent,stroke:transparent,stroke-width:1px
style ProductSearchStep fill:transparent,stroke:transparent,stroke-width:1px
style StatusUpdateStep fill:transparent,stroke:transparent,stroke-width:1px
詳細データフロー依存関係
ローカルDB同期コンポーネントは以下のデータフローに従います:
- 新しいランキングデータは最初にCrawlerシステムによって一時テーブル(
t_category_rankings、t_sq_rankings)に保存される localdb:sync-product-category-rankingsとlocaldb:sync-product-search-query-rankingsコマンドが一時テーブルでstatus =0 未同期のレコードを識別- カテゴリランキングの場合:
- カテゴリデータが抽出され
category_rankingsテーブルに保存される - 商品ランキングデータが処理され
product_category_rankingsテーブルに保存される
- カテゴリデータが抽出され
- 検索クエリランキングの場合:
- 検索クエリデータが抽出され
search_query_rankingsテーブルに保存される - 商品ランキングデータが処理され
product_search_query_rankingsテーブルに保存される
- 検索クエリデータが抽出され
- 処理された一時レコードは
status =1 同期済みでマークされる
頻度概要
タイムライン
timeline
title ローカルDB同期スケジュール
section 定期操作
5分ごと<br>(例: 08.00, 08.05) : localdb sync-product-category-rankings
: localdb sync-product-search-query-rankings
エンドユーザーへの影響
これらのコマンドが正常に実行されると、エンドユーザーは以下の恩恵を受けます:
- 包括的なカテゴリ分析のための完全な商品カテゴリランキング情報
- 検索パフォーマンス監視のための正確な商品検索クエリランキングデータ
- ローカルデータベース内での一貫したデータ整合性
- 頻繁なチェックによる欠損ランキングデータの信頼性の高い復旧
- カテゴリと検索パフォーマンスの強化された分析機能
- カテゴリと検索結果全体での商品ポジショニングのリアルタイム可視性
- 異なるマーケットプレイスと時間期間にわたるトレンド識別
データベーススキーマ
erDiagram
t_category_rankings {
bigint id PK
string product_id "商品ID(nullable、indexed)"
integer mall_id "モール識別子(nullable、indexed)"
string title "商品タイトル(nullable)"
float price "商品価格(nullable)"
string image "商品画像URL(nullable、max 1000 chars)"
string shop_url "ショップページURL(nullable、max 1000 chars)"
string shop_name "ショップ名(nullable)"
string product_url "商品ページURL(nullable、max 1000 chars)"
string category_id "カテゴリID(nullable、indexed)"
string category_name "カテゴリ名(nullable)"
integer ranking "カテゴリ内商品ランク(nullable)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
tinyint status "同期状態: 0=未同期、1=同期済み(default 0、indexed)"
}
t_sq_rankings {
bigint id PK
string image "商品画像URL(nullable、max 255 chars)"
integer point "商品ポイント(nullable)"
float price "商品価格(nullable)"
string title "商品タイトル(nullable、max 255 chars)"
string keyword "検索キーワード(nullable、indexed、max 100 chars)"
integer mall_id "モール識別子(nullable、indexed)"
integer ranking "キーワードの商品ランキング(nullable)"
tinyint sponsor "スポンサー商品フラグ(nullable)"
string shop_url "ショップURL(nullable、max 255 chars)"
string shop_name "ショップ名(nullable、max 100 chars)"
string product_id "商品識別子(nullable、indexed)"
string product_url "商品URL(nullable、max 255 chars)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
tinyint status "同期状態: 0=未同期、1=同期済み(default 0、indexed)"
}
category_rankings {
bigint id PK
string mall_category_id "モールシステムのカテゴリID(indexed)"
string mall_category_name "モールのカテゴリ名(nullable)"
integer mall_id "モール識別子"
string unique_key "システム生成の一意キー(unique、indexed、utf8mb4_bin)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
}
search_query_rankings {
bigint id PK
string keyword "検索クエリテキスト(unique、indexed)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
}
product_category_rankings {
bigint id PK
bigint category_ranking_id FK
integer ranking "カテゴリ内商品ランク(default 0、indexed)"
string mall_product_id "モールシステムの商品ID(indexed)"
string product_name "商品名"
double price "商品価格(default 0)"
string shop_name "ショップ名"
text image "商品画像URL"
tinytext product_url "商品ページURL"
tinytext shop_url "ショップページURL"
tinyint mall_id "モール識別子(indexed)"
string unique_key "システム生成の一意キー(unique、indexed、utf8mb4_bin)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
}
product_search_query_rankings {
bigint id PK
bigint search_query_ranking_id FK
string mall_product_id "asinまたはrakuten_id(indexed)"
text product_name "商品名"
text image "商品画像URL"
tinytext product_url "商品ページURL"
tinytext shop_url "ショップページURL(nullable)"
string shop_name "ショップ名(nullable)"
tinyint sponsor "0: オーガニック、1: SP、2: AB(default 0、indexed)"
float point "ポイント(default 0)"
integer mall_id "モール識別子(default 0、indexed)"
integer ranking "検索クエリの商品ランク(default 0、indexed)"
string unique_key "システム生成の一意キー(unique、indexed、utf8mb4_bin)"
timestamp crawl_created_at "クローラーからのタイムスタンプ(nullable、indexed)"
}
t_category_rankings ||--o{ category_rankings : "同期先"
t_category_rankings ||--o{ product_category_rankings : "同期先"
t_sq_rankings ||--o{ search_query_rankings : "同期先"
t_sq_rankings ||--o{ product_search_query_rankings : "同期先"
category_rankings ||--o{ product_category_rankings : "ランキングを持つ"
search_query_rankings ||--o{ product_search_query_rankings : "ランキングを持つ"
テーブルカテゴリ
一時テーブル(Crawlerによって入力)
- t_category_rankings: 同期状態追跡付きの一時カテゴリランキングデータを保持
- t_sq_rankings: 同期状態追跡付きの一時検索クエリランキングデータを保持
メインテーブル(ローカルDB同期によって入力)
- category_rankings: 一時データから抽出された一意のカテゴリ情報を保存
- search_query_rankings: 一時データから抽出された一意の検索クエリを保存
- product_category_rankings: カテゴリ内の詳細な商品ランキングを保存
- product_search_query_rankings: 検索クエリの詳細な商品ランキングを保存
バッチリスト
| 名前 | 説明 |
|---|---|
| 欠損ランキング同期 | 一時テーブルからメインテーブルにランキングデータを同期するために5分ごとに実行されるコマンド |