# Querying Daton created tables on RedShift

### Querying Daton created tables on RedShift

RedShift data warehouse does not support nested tables. Hence, Daton creates separate 'child' tables for each nested data present in source schema(or parent table).&#x20;

#### At present Daton creates separate child tables up to three levels.&#x20;

For example, if data is present in *Listrecommendations.Fulfillmentrecommendations.Member.Itemdimensions.Dimensiondescription*then the following tables would be created -&#x20;

1. Listrecommendations (Parent Table)
2. Listrecommendations\_Fulfillmentrecommendations (Level 1 Child)
3. Listrecommendations\_Fulfillmentrecommendations\_Member (Level 2 Child)
4. Listrecommendations\_Fulfillmentrecommendations\_Member\_Itemdimensions (Level 3 Child)

Any nested data present in Itemdimesions would be stored at *text*  and any excess data which does not fit into that field would be truncated.

#### Data Mapping

Data between parent and child tables can be mapped or combined using *daton\_parent\_batch\_id* and *daton\_batch\_runtime* meta fields. The same applies for other levels of child tables.&#x20;

For example, if API response for ListOrderItems contains data in the following structure&#x20;

| Column Name            | Datatype |
| ---------------------- | -------- |
| AmazonOrderId          | STRING   |
| ASIN                   | STRING   |
| SellerSKU              | STRING   |
| OrderItemId            | STRING   |
| ItemPrice              | RECORD   |
| ItemPrice.CurrencyCode | STRING   |
| ItemPrice.Amount       | STRING   |

then the following tables would be created by Daton on RedShift

**`Table 1:`**` ``ListOrderItem (Parent Table)`

| Column Name           | Datatype |
| --------------------- | -------- |
| AmazonOrderId         | STRING   |
| ASIN                  | STRING   |
| SellerSKU             | STRING   |
| OrderItemId           | STRING   |
| daton\_user\_id       | NUMERIC  |
| daton\_batch\_runtime | NUMERIC  |
| daton\_batch\_id      | NUMERIC  |

**`Table 2:`**` ``ListOrderItem_ItemPrice (Level 1 Child Table)`

| Column Name              | Datatype |
| ------------------------ | -------- |
| CurrencyCode             | STRING   |
| Amount                   | STRING   |
| daton\_user\_id          | NUMERIC  |
| daton\_batch\_runtime    | NUMERIC  |
| daton\_batch\_id         | NUMERIC  |
| daton\_parent\_batch\_id | NUMERIC  |

In order to fetch Item price for an *AmazonOrderId,* daton\_batch\_id and daton\_batch\_runtime must be used for mapping records

```
select  Amount from listorderitems_itemprice
where 
daton_parent_batch_id = (select daton_batch_id from mws_listorderitems where amazonorderid = 'XXX-7370285-XXXX')
and
daton_batch_runtime = (select daton_batch_runtime from mws_listorderitems where amazonorderid = 'XXX-7370285-XXXX')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daton-sarasanalytics.gitbook.io/daton/integrations/destinations/amazon-redshift/querying-daton-created-tables-on-redshift.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
