# Step 1: Prepare Your Snowflake Data

Organize your Snowflake tables to match the Parent Segment data model: **one Customers table and one or more Behaviors tables.**

## Customers Table

The Customers table is the **single source of all profile data and attributes.** Every column you want to use for segmentation **must be in this table.**

| Requirement | Description |
|  --- | --- |
| Unique key column | A column with **unique values per customer** (e.g., `cdp_customer_id`) |
| No duplicate keys | Each row must represent a unique customer profile |
| All attributes | All customer properties for segmentation must be columns in this table |


### Example Customers Table

| cdp_customer_id | email | first_name | last_name | city | country | gender | membership_tier | ltv | aov | next_best_channel | next_best_offer |
|  --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 001 | alice@example.com | Alice | Smith | Tokyo | JP | F | Gold | 5000 | 120 | email | discount_20 |
| 002 | bob@example.com | Bob | Jones | Osaka | JP | M | Silver | 2500 | 80 | push | free_shipping |


## Behaviors Tables

Each Behaviors table represents a specific type of customer activity. You can define multiple Behaviors tables (e.g., page views, purchases, email clicks).

| Requirement | Description |
|  --- | --- |
| Key column | Must contain a column with the same customer identifier used in the Customers table (e.g., `cdp_customer_id`) to join the two tables |
| Time column | Timestamp column for the event (e.g., `time`) |
| Event columns | Additional columns describing the event details |


### Example Behaviors Table

| cdp_customer_id | time | td_url | td_title |
|  --- | --- | --- | --- |
| 001 | 2025-11-20 10:30:00 | https://example.com/products | Products Page |
| 001 | 2025-11-20 11:00:00 | https://example.com/cart | Shopping Cart |
| 002 | 2025-11-20 12:15:00 | https://example.com/sale | Sale Page |


## Snowflake Permissions

To ensure the Parent Segment can access your Snowflake data, grant the following permissions to the Snowflake user account you will specify when creating the connection in Treasure Data:


```sql
-- Grant usage on the warehouse, database, and schema
GRANT USAGE ON WAREHOUSE <warehouse_name> TO ROLE <role_name>;
GRANT USAGE ON DATABASE <database_name> TO ROLE <role_name>;
GRANT USAGE ON SCHEMA <database_name>.<schema_name> TO ROLE <role_name>;

-- Grant SELECT on the Customers table
GRANT SELECT ON TABLE <database_name>.<schema_name>.customers TO ROLE <role_name>;

-- Grant SELECT on each Behaviors table
GRANT SELECT ON TABLE <database_name>.<schema_name>.behavior_pageviews TO ROLE <role_name>;
-- Repeat for each Behaviors table

-- Grant CREATE TABLE on the schema to create and clean up temporary tables during activation
GRANT CREATE TABLE ON SCHEMA <database_name>.<schema_name> TO ROLE <role_name>;
```

## Whitelist Treasure Data IP Addresses

To allow Treasure Data to communicate with your Snowflake instance, you must whitelist their rotating IP addresses in your Snowflake Network Policy:


```sql
ALTER NETWORK POLICY <policy_name> SET ALLOWED_IP_LIST = ('<TD_IP_1>', '<TD_IP_2>');
```

See [Static IP Addresses for Integrations and Result Workers](/apis/endpoints/ip-addresses-integrations-result-workers) for the most current list based on your specific region. Please whitelist both the Import and Export tabs.