<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Amazon+SimpleDB+Translator">Amazon SimpleDB Translator</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://docs.jboss.org/author/display/~rareddy">Ramesh Reddy</a>
    </h4>
        <br/>
                         <h4>Changes (19)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h1. *SimpleDB Translator* <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h1. *Amazon SimpleDB Translator* <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The SimpleDB Translator, known by the type name&amp;nbsp;_simpledb_, exposes querying functionality to [SimpleDB Data Sources].  The translator translates Teiid push down commands into [SimpleDB queries|http://aws.amazon.com/simpledb/]. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The Amazon SimpleDB Translator, known by the type name _simpledb_, exposes querying functionality to [Amazon SimpleDB Data Sources]. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{info:title=&quot;Amazon SimpleDB&quot;} <br>Amazon SimpleDB is a web service for running queries on structured data in real time. This service works in close conjunction with Amazon Simple Storage Service (Amazon S3) and Amazon Elastic Compute Cloud (Amazon EC2), collectively providing the ability to store, process and query data sets in the cloud. These services are designed to make web-scale computing easier and more cost-effective for developers. Read more about it at [http://aws.amazon.com/simpledb/| Amazon SimpleDB] <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*Properties*</span> <span class="diff-added-words"style="background-color: #dfd;">{info}</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The SimpleDB Translator currently has no import or execution properties. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">This translator provides an easy way connect to Amazon SimpleDB and provides relational way using SQL to add records from directly from user or from other sources that are integrated with Teiid. It also gives ability to read/update/delete existing records from SimpleDB store. <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br>h3. *Usage* <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Amazon SimpleDB is hosted key/value store where a single key can contain host multiple attribute name/value pairs where where value can also be a multi-value. The data structure can be represented by <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The SimpleDB Translator supports SELECT statements with a restrictive set of capabilities including: comparison predicates, IN predicates, and LIMIT. Consider a custom extension or create an enhancement request should your usage require additional capabilities. Insert, update, delete are also supported. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">!simpledb-key.png|border=1! <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Multi-valued properties are supported and handled as bracketed semi-colon delimited lists. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Based on above data structure, when you import the metadata from SimpleDB into Teiid, the constructs are aligned as below <br>||Simple DB Name || SQL (Teiid)|| <br>|Domain|Table| <br>|Item Name|Column (ItemName) Primary Key| <br>|attribute - single value |Column - String Datatype| <br>|attribute - multi value |Column - String Array Datatype| <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3. Native Queries <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Since all attributes are by default are considered as string data types, columns are defined with string data type. However, during modeling of the schema in Designer, one can use various other data types supported through Teiid to define a data type of column, that user wishes to expose as.  <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Not yet supported. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning} <br>If you did modify data type be other than string based, be cautioned and do not use those columns in comparison queries, as SimpleDB does only lexicographical matching. To avoid it, set the &quot;SearchType&quot; on that column to &quot;UnSearchable&quot;.   <br>{warning} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">An Example Dynamic VDB that shows SimpleDB translator can be defined as <br> <br>{code:title=&quot;simpledb-vdb.xml&quot;} <br>&lt;vdb name=&quot;myvdb&quot; version=&quot;1&quot;&gt; <br>    &lt;model name=&quot;simpledb&quot;&gt; <br>        &lt;source name=&quot;node&quot; translator-name=&quot;simpledb&quot; connection-jndi-name=&quot;java:/simpledbDS&quot;/&gt; <br>    &lt;/model&gt; <br>&lt;vdb&gt; <br>{code} <br> <br>The translator does NOT provide a connection to the SimpleDB. For that purpose, Teiid has a JCA adapter that provides a connection to SimpleDB using Amazon SDK Java libraries. To define such connector, see Amazon SimpleDB Data Sources or see an example in &quot;&lt;jboss-as&gt;/docs/teiid/datasources/simpledb&quot; <br> <br>If you are using Designer Tooling, to create VDB <br> <br>Create/use a Teiid Designer Model project <br>Use &quot;Teiid Connection &gt;&gt; Source Model&quot; importer, create SimpleDB Data Source using data source creation wizard and use _simpledb_ as translator in the importer. The table(s) is created in a source model by the time you finish with this importer, if the data is already defined on Amazon SimpleDB. <br> <br>Create a VDB and deploy into Teiid Server and use either jdbc, odbc, odata etc to query. <br> <br>h3. Properties <br> <br>The Amazon SimpleDB Translator currently has no import or execution properties. <br> <br>h3. Capabilities <br> <br>The Amazon SimpleDB Translator supports SELECT statements with a restrictive set of capabilities including: comparison predicates, IN predicates, LIMIT and ORDER BY. Insert, update, delete are also supported.  <br> <br>*Queries on Attributes with Multiple Values* <br> <br>Attributes with multiple values will defined as string array type. So this column is treated SQL Array type. The below table shows SimpleDB way of querying to Teiid way to query. The queries are based on http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/RangeValueQueriesSelect.html <br> <br>||SimpleDB Query||Teiid Query|| <br>|select * from mydomain where Rating = &#39;4 stars&#39; or Rating = &#39;****&#39;|select * from mydomain where Rating = (&#39;4 stars&#39;,&#39;****&#39;)| <br>|select * from mydomain where Keyword = &#39;Book&#39; and Keyword = &#39;Hardcover&#39;|select * from mydomain where intersection(Keyword,&#39;Book&#39;,&#39;Hardcover&#39;)| <br>|select * from mydomain where every(Rating) = &#39;****&#39;|select * from mydomain where every(Rating) = &#39;****&#39;| <br> <br>With Insert/Update/Delete you write prepare statements or you can write SQL like <br> <br>{code:lang=SQL} <br>INSERT INTO mydomain (ItemName, title, author, year, pages, keyword, rating) values (&#39;0385333498&#39;, &#39;The Sirens of Titan&#39;, &#39;Kurt Vonnegut&#39;, (&#39;1959&#39;), (&#39;Book&#39;, Paperback&#39;), (&#39;*****&#39;,&#39;5 stars&#39;,&#39;Excellent&#39;)) <br>{code} <br> <br>h3. Direct Query Support <br>{warning} <br>This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the execution property called SupportsDirectQueryProcedure to true. <br>{warning} <br>{info} <br>By default the name of the procedure that executes the queries directly is called native. Override the execution property DirectQueryProcedureName to change it to another name. <br>{info} <br>The SimpleDB translator provides a procedure to execute any ad-hoc simpledb query directly against the source without Teiid parsing or resolving. Since the metadata of this procedure&#39;s results are not known to Teiid, they are returned as an object array. ARRAYTABLE can be used construct tabular output for consumption by client applications. Direct query supported for &quot;select&quot; based calls. <br> <br>{code:title=&quot;Example Code&quot;} <br> <br>SELECT X.*  <br>  FROM simpledb_source.native(&#39;SELECT firstname, lastname FROM users&#39;) n, ARRAYTABLE(n.tuple COLUMNS firstname string, lastname string) AS X <br>{code} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. *JCA Resource Adapter* <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The Teiid specific <span class="diff-added-words"style="background-color: #dfd;">Amazon</span> SimpleDB Resource Adapter should be used with this translator.  See <span class="diff-changed-words">[<span class="diff-added-chars"style="background-color: #dfd;">Amazon </span>SimpleDB</span> Data Sources] for connecting to SimpleDB. <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="AmazonSimpleDBTranslator-AmazonSimpleDBTranslator"></a><b>Amazon SimpleDB Translator</b></h1>

<p>The Amazon SimpleDB Translator, known by the type name <em>simpledb</em>, exposes querying functionality to <a href="/author/pages/createpage.action?spaceKey=TEIID&amp;title=Amazon+SimpleDB+Data+Sources&amp;linkCreation=true&amp;fromPageId=75990303" class="createlink">Amazon SimpleDB Data Sources</a>.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>"Amazon SimpleDB"</b><br />Amazon SimpleDB is a web service for running queries on structured data in real time. This service works in close conjunction with Amazon Simple Storage Service (Amazon S3) and Amazon Elastic Compute Cloud (Amazon EC2), collectively providing the ability to store, process and query data sets in the cloud. These services are designed to make web-scale computing easier and more cost-effective for developers. Read more about it at <a href="/author/pages/createpage.action?spaceKey=TEIID&amp;title=Amazon+SimpleDB&amp;linkCreation=true&amp;fromPageId=75990303" class="createlink">http://aws.amazon.com/simpledb/</a></td></tr></table></div> 

<p>This translator provides an easy way connect to Amazon SimpleDB and provides relational way using SQL to add records from directly from user or from other sources that are integrated with Teiid. It also gives ability to read/update/delete existing records from SimpleDB store.</p>


<h3><a name="AmazonSimpleDBTranslator-Usage"></a><b>Usage</b></h3>
<p>Amazon SimpleDB is hosted key/value store where a single key can contain host multiple attribute name/value pairs where where value can also be a multi-value. The data structure can be represented by</p>

<p><span class="image-wrap" style=""><img src="/author/download/attachments/75990303/simpledb-key.png?version=1&amp;modificationDate=1397071447642" style="border: 1px solid black" /></span></p>

<p>Based on above data structure, when you import the metadata from SimpleDB into Teiid, the constructs are aligned as below</p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Simple DB Name </th>
<th class='confluenceTh'> SQL (Teiid)</th>
</tr>
<tr>
<td class='confluenceTd'>Domain</td>
<td class='confluenceTd'>Table</td>
</tr>
<tr>
<td class='confluenceTd'>Item Name</td>
<td class='confluenceTd'>Column (ItemName) Primary Key</td>
</tr>
<tr>
<td class='confluenceTd'>attribute - single value </td>
<td class='confluenceTd'>Column - String Datatype</td>
</tr>
<tr>
<td class='confluenceTd'>attribute - multi value </td>
<td class='confluenceTd'>Column - String Array Datatype</td>
</tr>
</tbody></table>
</div>


<p>Since all attributes are by default are considered as string data types, columns are defined with string data type. However, during modeling of the schema in Designer, one can use various other data types supported through Teiid to define a data type of column, that user wishes to expose as. </p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>If you did modify data type be other than string based, be cautioned and do not use those columns in comparison queries, as SimpleDB does only lexicographical matching. To avoid it, set the "SearchType" on that column to "UnSearchable".</td></tr></table></div>

<p>An Example Dynamic VDB that shows SimpleDB translator can be defined as</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>"simpledb-vdb.xml"</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
&lt;vdb name="myvdb" version="1"&gt;
    &lt;model name="simpledb"&gt;
        &lt;source name="node" translator-name="simpledb" connection-jndi-name="java:/simpledbDS"/&gt;
    &lt;/model&gt;
&lt;vdb&gt;
</pre>
</div></div>

<p>The translator does NOT provide a connection to the SimpleDB. For that purpose, Teiid has a JCA adapter that provides a connection to SimpleDB using Amazon SDK Java libraries. To define such connector, see Amazon SimpleDB Data Sources or see an example in "&lt;jboss-as&gt;/docs/teiid/datasources/simpledb"</p>

<p>If you are using Designer Tooling, to create VDB</p>

<p>Create/use a Teiid Designer Model project<br/>
Use "Teiid Connection &gt;&gt; Source Model" importer, create SimpleDB Data Source using data source creation wizard and use <em>simpledb</em> as translator in the importer. The table(s) is created in a source model by the time you finish with this importer, if the data is already defined on Amazon SimpleDB.</p>

<p>Create a VDB and deploy into Teiid Server and use either jdbc, odbc, odata etc to query.</p>

<h3><a name="AmazonSimpleDBTranslator-Properties"></a>Properties</h3>

<p>The Amazon SimpleDB Translator currently has no import or execution properties.</p>

<h3><a name="AmazonSimpleDBTranslator-Capabilities"></a>Capabilities</h3>

<p>The Amazon SimpleDB Translator supports SELECT statements with a restrictive set of capabilities including: comparison predicates, IN predicates, LIMIT and ORDER BY. Insert, update, delete are also supported. </p>

<p><b>Queries on Attributes with Multiple Values</b></p>

<p>Attributes with multiple values will defined as string array type. So this column is treated SQL Array type. The below table shows SimpleDB way of querying to Teiid way to query. The queries are based on <a href="http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/RangeValueQueriesSelect.html" class="external-link" rel="nofollow">http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/RangeValueQueriesSelect.html</a></p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>SimpleDB Query</th>
<th class='confluenceTh'>Teiid Query</th>
</tr>
<tr>
<td class='confluenceTd'>select * from mydomain where Rating = '4 stars' or Rating = '****'</td>
<td class='confluenceTd'>select * from mydomain where Rating = ('4 stars','****')</td>
</tr>
<tr>
<td class='confluenceTd'>select * from mydomain where Keyword = 'Book' and Keyword = 'Hardcover'</td>
<td class='confluenceTd'>select * from mydomain where intersection(Keyword,'Book','Hardcover')</td>
</tr>
<tr>
<td class='confluenceTd'>select * from mydomain where every(Rating) = '****'</td>
<td class='confluenceTd'>select * from mydomain where every(Rating) = '****'</td>
</tr>
</tbody></table>
</div>


<p>With Insert/Update/Delete you write prepare statements or you can write SQL like</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: sql; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">
INSERT INTO mydomain (ItemName, title, author, year, pages, keyword, rating) values ('0385333498', 'The Sirens of Titan', 'Kurt Vonnegut', ('1959'), ('Book', Paperback'), ('*****','5 stars','Excellent'))
</pre>
</div></div>

<h3><a name="AmazonSimpleDBTranslator-DirectQuerySupport"></a>Direct Query Support</h3>
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This feature is turned off by default because of the security risk this exposes to execute any command against the source. To enable this feature, override the execution property called SupportsDirectQueryProcedure to true.</td></tr></table></div>
<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/author/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>By default the name of the procedure that executes the queries directly is called native. Override the execution property DirectQueryProcedureName to change it to another name.</td></tr></table></div>
<p>The SimpleDB translator provides a procedure to execute any ad-hoc simpledb query directly against the source without Teiid parsing or resolving. Since the metadata of this procedure's results are not known to Teiid, they are returned as an object array. ARRAYTABLE can be used construct tabular output for consumption by client applications. Direct query supported for "select" based calls.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader" style="border-bottom-width: 1px;"><b>"Example Code"</b></div><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false" style="font-size:12px; font-family: ConfluenceInstalledFont,monospace;">

SELECT X.* 
  FROM simpledb_source.native('SELECT firstname, lastname FROM users') n, ARRAYTABLE(n.tuple COLUMNS firstname string, lastname string) AS X
</pre>
</div></div>

<h3><a name="AmazonSimpleDBTranslator-JCAResourceAdapter"></a><b>JCA Resource Adapter</b></h3>

<p>The Teiid specific Amazon SimpleDB Resource Adapter should be used with this translator.  See <a href="/author/pages/createpage.action?spaceKey=TEIID&amp;title=Amazon+SimpleDB+Data+Sources&amp;linkCreation=true&amp;fromPageId=75990303" class="createlink">Amazon SimpleDB Data Sources</a> for connecting to SimpleDB.</p>



    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://docs.jboss.org/author/display/TEIID/Amazon+SimpleDB+Translator">View Online</a>
        |
        <a href="https://docs.jboss.org/author/pages/diffpagesbyversion.action?pageId=75990303&revisedVersion=3&originalVersion=2">View Changes</a>
                |
        <a href="https://docs.jboss.org/author/display/TEIID/Amazon+SimpleDB+Translator?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>