---
# System prepended metadata

title: DynamoDB HBase Replacement Solution

---

# Hbase Replacement with DynamoDB

**Tables**
- [Cardholder Network Deal](#Cardholder-Network-Deal)
- [Prewards Events](#Prewards-Events)

## Cardholder Network Deal

Questions:

- Cost Estimate
- Determine table structure

### Schema

~~All options need a hashed key infront of the actual `partitionKey` in order to enforce uniform distribution of the data and keep reads/writes fast. [Source](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-data-upload.html).~~

Update: turns out this hashing is not necessary. CardholderId accesses are uniform across all cardholders; partition key is hashed to create uniform distributed keys.

**Option 1:**

Single query executed for each getOffers API call
Query is still a single get request as long as it's < 100/ < 4KB

```json
{
    "partitionKey": "$cardholderId",
    "sortKey": "$networkDealNumber"
}
```

**Option 2:**

```json
{
    "partitionKey": "$cardholderId",
    "sortKey": null,
    "payload": ["$networkDealNumbers[]"]
}
```


### Write

**Option 1**

Read whole dynamodb table
Reconcile with written targeting partitions/targeting sets
Partial write update

**Option 2**

Update targeting process
Stop doing `insert overwrite partition`
Perform delta between new targeting set and old
Stage delta
Overwrite targeting set
Process all deltas, update dynamodb

## Prewards Events