# Schema

## Overview

These tables provide standardized geographic reference data used across the Bonsai platform. They map postal codes, regions, cities, and DMAs while supplying demographic indices to enable consistent geographic segmentation, modeling, and reporting.

***

### Geo Mapping

<details>

<summary><code>dma_table</code> schema<br><br><strong>Description:</strong> A reference table of DMA data for the Bonsai platform.</summary>

| field\_name | is\_nullable | data\_type | definition       |
| ----------- | ------------ | ---------- | ---------------- |
| dma\_id     | YES          | INT64      | Bonsai's DMA ID. |
| dma\_name   | YES          | STRING     | DMA name.        |

</details>

<details>

<summary><code>dma_demographics_indicies_data_table</code> schema<br><br><strong>Description:</strong> A reference table of DMA demographic and household indices for the Bonsai platform.</summary>

| field\_name         | is\_nullable | data\_type | definition                     |
| ------------------- | ------------ | ---------- | ------------------------------ |
| dma\_id             | YES          | INT64      | Bonsai's DMA ID.               |
| dma\_name           | YES          | STRING     | DMA name.                      |
| pop\_index          | YES          | FLOAT64    | US population index.           |
| tv\_index           | YES          | FLOAT64    | US TV household index.         |
| household\_index    | YES          | FLOAT64    | US household index.            |
| male\_index         | YES          | FLOAT64    | US male population index.      |
| female\_index       | YES          | FLOAT64    | US female population index.    |
| male\_1824\_index   | YES          | FLOAT64    | Male 18–24 population index.   |
| female\_1824\_index | YES          | FLOAT64    | Female 18–24 population index. |
| male\_2534\_index   | YES          | FLOAT64    | Male 25–34 population index.   |
| female\_2534\_index | YES          | FLOAT64    | Female 25–34 population index. |
| male\_3544\_index   | YES          | FLOAT64    | Male 35–44 population index.   |
| female\_3544\_index | YES          | FLOAT64    | Female 35–44 population index. |
| male\_4554\_index   | YES          | FLOAT64    | Male 45–54 population index.   |
| female\_4554\_index | YES          | FLOAT64    | Female 45–54 population index. |
| male\_5564\_index   | YES          | FLOAT64    | Male 55–64 population index.   |
| female\_5564\_index | YES          | FLOAT64    | Female 55–64 population index. |
| male\_65\_index     | YES          | FLOAT64    | Male 65+ population index.     |
| female\_65\_index   | YES          | FLOAT64    | Female 65+ population index.   |

</details>

<details>

<summary><code>zip_to_dma</code> schema<br><br><strong>Description:</strong> A reference table mapping US Postal Codes to Bonsai DMA IDs.</summary>

| field\_name | is\_nullable | data\_type | definition       |
| ----------- | ------------ | ---------- | ---------------- |
| zip\_code   | YES          | STRING     | US postal code.  |
| dma\_id     | YES          | INT64      | Bonsai's DMA ID. |

</details>

<details>

<summary><code>zip_to_region</code> schema<br><br><strong>Description:</strong> A reference table mapping US Postal Codes to US State/Region.</summary>

| field\_name  | is\_nullable | data\_type | definition                                                |
| ------------ | ------------ | ---------- | --------------------------------------------------------- |
| zip\_code    | YES          | STRING     | US postal code.                                           |
| region\_code | YES          | STRING     | Bonsai's region ID.                                       |
| region\_abbr | YES          | STRING     | Region abbreviation, typically the US state abbreviation. |
| region\_name | YES          | STRING     | Region name, typically referring to US state.             |

</details>

<details>

<summary><code>city</code> schema<br><br><strong>Description:</strong> A reference table of cities in the Bonsai platform.</summary>

| field\_name | is\_nullable | data\_type | definition        |
| ----------- | ------------ | ---------- | ----------------- |
| city\_id    | YES          | INT64      | Bonsai's city ID. |
| city\_name  | YES          | STRING     | City name.        |

</details>
