Tell me how you would handle a Salesforce scenario involving CDC (change data capture). Use PostgreSQL to identify the latest in-scope CDC event for each Salesforce account and associate it with the current account snapshot. Preserve events for deleted or otherwise unmatched accounts.
account_id, event_type, event_time, current_account_name, current_owner_id, and current_status.event_time descending, then account_id ascending.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Internal CDC event identifier |
| account_id | VARCHAR(18) | Salesforce account identifier |
| event_type | VARCHAR(20) | CDC operation type |
| event_time | TIMESTAMPTZ | Time when the CDC event occurred |
| replay_id | BIGINT | Salesforce CDC replay identifier |
| account_name | VARCHAR(150) | Account name included in the event payload |
| Column | Type | Description |
|---|---|---|
| account_idPK | VARCHAR(18) | Current Salesforce account identifier |
| account_name | VARCHAR(150) | Current account name |
| owner_id | VARCHAR(18) | Current Salesforce owner identifier |
| status | VARCHAR(30) | Current account status |