# database_price

> Managed database SKU prices per Region.

Primary key: `vendor_id`, `region_id`, `database_id`, `allocation`, `ha`, `ha_strategy`. See the [version history of this table on dbdocs.io](https://dbdocs.io/spare-cores/sc-crawler?table=database_price&schema=public&view=table_structure).

## Columns

| Column | Type | Constraints | References | Description |
| --- | --- | --- | --- | --- |
| `vendor_id` | `VARCHAR(255)` | PK | [`vendor.vendor_id`](https://docs.sparecores.com/schemas/tables/vendor.md) | Reference to the Vendor. |
| `region_id` | `VARCHAR(255)` | PK | [`region.region_id`](https://docs.sparecores.com/schemas/tables/region.md) | Reference to the Region. |
| `database_id` | `VARCHAR(255)` | PK | [`database.database_id`](https://docs.sparecores.com/schemas/tables/database.md) | Reference to the Database. |
| `allocation` | `ENUM` | PK |  | Allocation method, e.g. on-demand or spot. See [Allocation](#allocation) for the possible values. |
| `ha` | `ENUM` | PK |  | HA level this price applies to. See [DatabaseHaLevel](#databasehalevel) for the possible values. |
| `ha_strategy` | `ENUM` | PK |  | HA strategy this price applies to. See [DatabaseHaStrategy](#databasehastrategy) for the possible values. |
| `unit` | `ENUM` | NOT NULL |  | Billing unit of the pricing model. See [PriceUnit](#priceunit) for the possible values. |
| `price` | `FLOAT` | NOT NULL |  | Actual price of a billing unit. |
| `price_upfront` | `FLOAT` | NOT NULL |  | Price to be paid when setting up the resource. |
| `price_tiered` | `JSON` | NOT NULL |  | List of pricing tiers with min/max thresholds and actual prices. |
| `currency` | `VARCHAR(255)` | NOT NULL |  | Currency of the prices. |
| `status` | `ENUM` | NOT NULL |  | Status of the resource (active or inactive). See [Status](#status) for the possible values. |
| `observed_at` | `DATETIME` | NOT NULL |  | Timestamp of the last observation. |

## Foreign keys

- `vendor_id`, `region_id` → [`region`](https://docs.sparecores.com/schemas/tables/region.md) (`vendor_id`, `region_id`)
- `vendor_id`, `database_id` → [`database`](https://docs.sparecores.com/schemas/tables/database.md) (`vendor_id`, `database_id`)
- `vendor_id` → [`vendor`](https://docs.sparecores.com/schemas/tables/vendor.md) (`vendor_id`)

## Enums

### Allocation

Server allocation options.

| Value | Description |
| --- | --- |
| `ONDEMAND` | On-demand server. |
| `RESERVED` | Reserved server. |
| `SPOT` | Spot/preemptible server. |

### DatabaseHaLevel

High availability level for a managed database type.

| Value | Description |
| --- | --- |
| `NONE` | No high availability. |
| `SINGLE_ZONE` | Single-zone high availability, meaning multiple databases in the same zone with failover or multi-master. |
| `MULTI_ZONE` | Multi-zone high availability, meaning multiple databases in multiple zones of the same region with failover or multi-master. |
| `MULTI_REGION` | Multi-region high availability, meaning multiple databases in multiple regions with failover or multi-master. |

### DatabaseHaStrategy

High availability replication strategy for a managed database type.

| Value | Description |
| --- | --- |
| `NONE` | No high availability strategy. |
| `PASSIVE_STANDBY` | Passive standby for failover, e.g. standard RDS Multi-AZ with block storage replication. |
| `READABLE_CLUSTER` | Readable cluster for read scaling and failover, e.g. RDS Multi-AZ Cluster / Aurora with engine replication. |
| `MULTI_MASTER` | True multi-master, e.g. CockroachDB / Spanner / DynamoDB Global Tables. |

### PriceUnit

Supported units for the price tables.

| Value | Description |
| --- | --- |
| `YEAR` | Price per year. |
| `MONTH` | Price per month. |
| `HOUR` | Price per hour. |
| `GIB` | Price per gibibyte (GiB). |
| `GB` | Price per gigabyte (GB). |
| `GB_MONTH` | Price per gigabyte (GB)/month. |

### Status

Last known status of a record.

The docstrings of the values are shown to end-users (e.g. in the API and
on the website), so keep those to what a status means, and document here
how the statuses are set:

- `ACTIVE` and `INACTIVE` are valid for all tables. Records returned by
  the vendor or defined in code are `ACTIVE`. Records no longer returned
  or defined are set to `INACTIVE` by `pull`, as well as records missing
  from the source by `sync`.
- `PLANNED_FOR_RETIREMENT` and `RETIRED` are only valid for Server and
  Database, and are set only from explicit vendor signals. These are kept
  by `pull` when the record is no longer returned by the vendor.
- `ARCHIVED` is valid for all tables. It is set only from the
  [archive rules][sc_crawler.archive_rules] by `pull` and `sync`, also for
  child records (e.g. prices of a region), and archived records are not
  updated afterwards. It is our decision on the identity of a record,
  never a vendor signal: end of sale is `RETIRED`, and records no longer
  returned by a vendor are `INACTIVE`.

| Value | Description |
| --- | --- |
| `ACTIVE` | Currently available. |
| `INACTIVE` | Currently not available, without a known retirement. May become available again. |
| `PLANNED_FOR_RETIREMENT` | Retirement was announced by the vendor, but can still be ordered. Only used for servers and databases. |
| `RETIRED` | Retired by the vendor and cannot be ordered anymore, but prices may still exist (e.g. for active multi-year contracts). Only used for servers and databases. |
| `ARCHIVED` | Kept only for historical reference: replaced by another record (e.g. renamed, merged or split) or dropped from the dataset. |
