# SendGrid schema ERD

Table and field reference for the Fivetran SendGrid connector.

## Table & Field Reference

### unsubscribe_group

| Column | Type | Keys |
| --- | --- | --- |
| id | Long | PK |
| description | String |  |
| is_default | Boolean |  |
| last_email_sent_at | Instant |  |
| name | String |  |
| unsubscribes | Long |  |

### event

| Column | Type | Keys |
| --- | --- | --- |
| _fivetran_id | String | PK |
| campaign_id | Long | FK |
| singlesend_id | String | FK |
| attempt | Long |  |
| campaign_split_id | String |  |
| campaign_version | String |  |
| cert_err | String |  |
| email | String |  |
| event | String |  |
| ip | String |  |
| mc_stats | String |  |
| phase_id | String |  |
| pool_id | String |  |
| pool_name | String |  |
| post_type | String |  |
| reason | String |  |
| response | String |  |
| send_at | String |  |
| sg_event_id | String |  |
| sg_machine_open | Boolean |  |
| sg_message_id | String |  |
| sg_user_id | String |  |
| singlesend_name | String |  |
| smtp_id | String |  |
| status | String |  |
| timestamp | Instant |  |
| tls | String |  |
| type | String |  |
| url | String |  |
| url_offset_index | Long |  |
| url_offset_type | String |  |
| useragent | String |  |

### contact

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| address_line_1 | String |  |
| address_line_2 | String |  |
| city | String |  |
| country | String |  |
| created_at | Instant |  |
| email | String |  |
| facebook | String |  |
| first_name | String |  |
| last_name | String |  |
| line | String |  |
| phone_number | String |  |
| postal_code | String |  |
| state_province_region | String |  |
| unique_name | String |  |
| updated_at | Instant |  |
| whatsapp | String |  |

### campaign_segment

| Column | Type | Keys |
| --- | --- | --- |
| campaign_id | String | PK, FK |
| segment_id | String | PK, FK |

### recipient_list

| Column | Type | Keys |
| --- | --- | --- |
| list_id | String | PK, FK |
| recipient_id | String | PK, FK |

### campaign

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| sender_id | Long | FK |
| unsubscribe_group_id | Int | FK |
| custom_unsubscribe_url | String |  |
| editor | String |  |
| html_content | String |  |
| ip_pool | String |  |
| plain_content | String |  |
| status | String |  |
| subject | String |  |
| title | String |  |

### segment_condition

| Column | Type | Keys |
| --- | --- | --- |
| field | String | PK |
| segment_id | String | PK, FK |
| operator | String |  |
| value | String |  |

### campaign_list

| Column | Type | Keys |
| --- | --- | --- |
| campaign_id | String | PK, FK |
| list_id | String | PK, FK |

### sender

| Column | Type | Keys |
| --- | --- | --- |
| id | Long | PK |
| address | String |  |
| address_2 | String |  |
| city | String |  |
| country | String |  |
| created_at | Instant |  |
| from_email | String |  |
| from_name | String |  |
| locked | Boolean |  |
| nickname | String |  |
| reply_to_email | String |  |
| reply_to_name | String |  |
| state | String |  |
| updated_at | Instant |  |
| verified_reason | String |  |
| verified_status | Boolean |  |
| zip | String |  |

### list

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| name | String |  |

### segment

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| list_id | String | FK |
| condition | String |  |
| created_at | Instant |  |
| name | String |  |
| sample_updated_at | Instant |  |
| updated_at | Instant |  |

### contact_list

| Column | Type | Keys |
| --- | --- | --- |
| contact_id | String | PK, FK |
| list_id | String | PK, FK |

### single_send

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| email_config_sender_id | Long | FK |
| email_config_unsubscribe_group_id | Int | FK |
| created_at | String |  |
| email_config_custom_unsubscribe_url | String |  |
| email_config_editor | String |  |
| email_config_html_content | String |  |
| email_config_ip_pool | String |  |
| email_config_plain_content | String |  |
| email_config_subject | String |  |
| name | String |  |
| send_at | String |  |
| status | String |  |
| updated_at | String |  |

### single_send_list

| Column | Type | Keys |
| --- | --- | --- |
| list_id | String | PK, FK |
| single_send_id | String | PK, FK |

### contact_alternate_email

| Column | Type | Keys |
| --- | --- | --- |
| alternate_email | String | PK |
| contact_id | String | PK, FK |

### category

| Column | Type | Keys |
| --- | --- | --- |
| index | Int | PK |
| event_id | String | PK, FK |
| campaign_id | Long | FK |
| singlesend_id | String | FK |
| category | String |  |

### single_send_segment

| Column | Type | Keys |
| --- | --- | --- |
| segment_id | String | PK, FK |
| single_send_id | String | PK, FK |

### recipient

| Column | Type | Keys |
| --- | --- | --- |
| id | String | PK |
| created_at | Instant |  |
| email | String |  |
| first_name | String |  |
| last_clicked | Instant |  |
| last_emailed | Instant |  |
| last_name | String |  |
| last_opened | Instant |  |
| updated_at | Instant |  |

## Relationships

- event(singlesend_id) → single_send(id)
- event(campaign_id) → campaign(id)
- campaign_segment(segment_id) → segment(id)
- campaign_segment(campaign_id) → campaign(id)
- recipient_list(list_id) → list(id)
- recipient_list(recipient_id) → recipient(id)
- campaign(sender_id) → sender(id)
- campaign(unsubscribe_group_id) → unsubscribe_group(id)
- segment_condition(segment_id) → segment(id)
- campaign_list(list_id) → list(id)
- campaign_list(campaign_id) → campaign(id)
- segment(list_id) → list(id)
- contact_list(contact_id) → contact(id)
- contact_list(list_id) → list(id)
- single_send(email_config_sender_id) → sender(id)
- single_send(email_config_unsubscribe_group_id) → unsubscribe_group(id)
- single_send_list(list_id) → list(id)
- single_send_list(single_send_id) → single_send(id)
- contact_alternate_email(contact_id) → contact(id)
- category(event_id) → event(_fivetran_id)
- category(singlesend_id) → single_send(id)
- category(campaign_id) → campaign(id)
- single_send_segment(segment_id) → segment(id)
- single_send_segment(single_send_id) → single_send(id)
