> For the complete documentation index, see [llms.txt](https://daton-sarasanalytics.gitbook.io/daton/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://daton-sarasanalytics.gitbook.io/daton/~/changes/1yNKwtXwaJMWImmUJtdv/integrations/destinations/amazon-redshift/querying-daton-created-tables-on-redshift.md).

# 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')
```
