# Economy Data Structure

## Tabel Aktif: `economies`

Tabel ini digunakan untuk menyimpan data ekonomi dari World Bank API.

### Struktur:
- `id` - Primary key
- `country_code` - ISO3 code (e.g., IDN, USA, CHN)
- `year` - Tahun data
- `gdp` - Gross Domestic Product (USD)
- `inflation` - Tingkat inflasi (%)
- `population` - Jumlah penduduk
- `exports` - Nilai ekspor (USD)
- `imports` - Nilai impor (USD)
- `timestamps`

### Unique Constraint:
`(country_code, year)` - Satu negara hanya memiliki satu data per tahun

### Model: `App\Models\Economy`

### Relasi dengan Country:
```php
// Di Country model
public function economies(): HasMany
{
    return $this->hasMany(Economy::class, 'country_code', 'iso3');
}

public function latestEconomy(): HasOne
{
    return $this->hasOne(Economy::class, 'country_code', 'iso3')->latestOfMany('year');
}
```

### Sync Command:
```bash
php artisan countries:sync --economy
```

### Data Source:
World Bank API (https://api.worldbank.org/v2/)

---

## ⚠️ Catatan: Tabel `country_economies`

Tabel ini adalah struktur lama yang **TIDAK DIGUNAKAN**.
- Status: EMPTY (kosong)
- Model: Sudah dihapus
- Dapat di-drop jika diperlukan cleanup database

Aplikasi secara konsisten menggunakan tabel `economies` untuk semua operasi ekonomi.
