1er
This commit is contained in:
83
docs/db_structure.md
Normal file
83
docs/db_structure.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# Structure base de données
|
||||
|
||||
## Vue d'ensemble
|
||||
- `products` : produit suivi (URL canonique, store, catégories, statut).
|
||||
- `scrape_runs` : trace des runs pour mesurer taux réussite / blocages.
|
||||
- `product_snapshots` : historique des données extraites (prix, stock, badges, raw JSON).
|
||||
|
||||
## Diagramme
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌──────────────┐
|
||||
│ products │ 1 N │ product_ │
|
||||
│ (stores) │──────>│ snapshots │
|
||||
│ id PK │ │ id PK │
|
||||
│ store │ │ product_id FK│
|
||||
│ url │ │ scraped_at │
|
||||
│ asin │ │ price_current│
|
||||
│ ... │ │ stock_text │
|
||||
└─────────────┘ │ ... │
|
||||
└──────────────┘
|
||||
|
||||
┌──────────────┐
|
||||
│ scrape_runs │
|
||||
│ id PK │
|
||||
│ started_at │
|
||||
│ ended_at │
|
||||
│ status │
|
||||
│ items_ok │
|
||||
│ items_failed │
|
||||
│ items_total │
|
||||
└──────────────┘
|
||||
```
|
||||
|
||||
> Commentaire : `products` lie les snapshots ; `scrape_runs` peut être lié aux snapshots si on enregistre `scrape_run_id`.
|
||||
> Commentaire : les indexes `product_id`, `scraped_at` et `asin` servent à accélérer les historiques et recherches.
|
||||
|
||||
## Schéma base de données (SQLite)
|
||||
Proposer un schéma minimal + extensible.
|
||||
|
||||
### Tables
|
||||
1) `products`
|
||||
- `id` (PK)
|
||||
- `store` (ex: amazon_fr)
|
||||
- `url`
|
||||
- `asin`
|
||||
- `title`
|
||||
- `image_url`
|
||||
- `category`
|
||||
- `type`
|
||||
- `is_active` (bool)
|
||||
- `created_at`, `updated_at`
|
||||
|
||||
2) `scrape_runs`
|
||||
- `id` (PK)
|
||||
- `started_at`, `ended_at`
|
||||
- `status` (success/partial/failed)
|
||||
- `items_total`, `items_ok`, `items_failed`
|
||||
- `log_path` (option)
|
||||
|
||||
3) `product_snapshots`
|
||||
- `id` (PK)
|
||||
- `product_id` (FK → products.id)
|
||||
- `scraped_at`
|
||||
- `price_current`
|
||||
- `price_list` (nullable)
|
||||
- `lowest_30d_price` (nullable)
|
||||
- `stock_text` (nullable)
|
||||
- `in_stock` (nullable)
|
||||
- `rating_value` (nullable)
|
||||
- `rating_count` (nullable)
|
||||
- `prime_eligible` (nullable)
|
||||
- `amazon_choice` (nullable)
|
||||
- `limited_time_deal` (nullable)
|
||||
- `amazon_exclusive` (nullable)
|
||||
- `raw_json_path` (nullable)
|
||||
- `scrape_status` (ok/blocked/missing_fields/error)
|
||||
- `error_message` (nullable)
|
||||
|
||||
4) (option) `tags`
|
||||
- `id`, `name`
|
||||
|
||||
5) (option) `product_tags`
|
||||
- `product_id`, `tag_id`
|
||||
Reference in New Issue
Block a user