<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hi, I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/discussions/f/general/7257/hi-i-am-trying-to-map-a-composite-key-from-a-different-cdt-to-another-one</link><description>Hi, I am trying to map a composite key from a different CDT to another one using one unique key inside xsd. How do I do it? Two columns from one cdt form a composite pair and I have another foriegn key coming from that table which defines the relationship</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Hi, I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/73921?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 13:44:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bed9258e-80b3-4774-9f52-d4196e146466</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;You can import it, but you can&amp;#39;t actually use it. If you do this, you will see a message that says: &lt;em&gt;&amp;quot;Data types without primary keys, or with more than one primary key, prevent data stores from publishing. In order to publish a data store that contains this data type, you must modify the data type so that it has only one primary key, then publish the data store. Otherwise, the data store will be saved as a draft.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The CDT it self will be created but when you attempt to publish the data store it will fail. This means you can&amp;#39;t read or write to the database, so the CDT itself becomes essentially useless.&amp;nbsp;Composite keys are not supported in Appian when reading / writing to a database.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/73912?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 01:44:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b5034b8d-1274-4648-8182-b6f73c4c3f89</guid><dc:creator>AK47</dc:creator><description>&lt;p&gt;when creating CDT (Data Type), choose &amp;quot;create from database table or view&amp;quot;. If your database has the composite primary key, CDT also has it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29360?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 18:21:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ec657614-e734-42ba-808c-262a7520e115</guid><dc:creator>ChristineLHutchison</dc:creator><description>You need to map the @ID to a real column in the table or view and it can only map to one column. If your table does not have a unique column, one idea is to create a view that has a viewID column. That column can be a concat of the two columns with a separator in between (as 111 is not the same as 1_11 or 11_1). Then use this column as the @ID.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29351?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 17:03:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:74d9a0da-84ea-45bc-aba4-37475b5c7450</guid><dc:creator>PhilB</dc:creator><description>I&amp;#39;ll say it again - you can&amp;#39;t map a subCDT as an ID as you are doing in that XSD.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29350?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 17:01:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ce8c7295-e5a0-4e90-8250-3ff4bdc8c04a</guid><dc:creator>aswinb608</dc:creator><description>Hi,&lt;br /&gt;I have several variants of this subCDT inside the main cdt based on the type....attached is a generalized version of the CDT....based on the column &amp;quot;type&amp;quot; inside &amp;quot;default1&amp;quot; cdt i have different types of environments called uat, prod, commercial, test etc which are of type &amp;quot;default1&amp;quot;....which is the subCDT....I had early attached @Id at the beginning before the @Column....seeing above from sonalk&amp;#39;s code the only change I see is attaching @Id after @Column....but I still get that same error i mentioned above...attaching the xsd...&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/default1.xsd"&gt;default1.xsd&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29335?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 14:29:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f81bc3b8-ee4c-4f27-b3e3-7208acdefc48</guid><dc:creator>PhilB</dc:creator><description>@aswinb608 You can't map a composite key in the way you are attempting to. I believe the @Id annotation can only be used with a single column of, for example,  string or integer.&lt;br /&gt;&lt;br /&gt;You could select one of the composite keys and map that as an @Id, but you could see odd behaviour, such as only getting a single row when that key is actually repeated several times. This can actually work, provided any query against that table always uses that key.&lt;br /&gt;&lt;br /&gt;Your other alternatives (as mentioned above) are to have a view created that provides a unique identifier, or to use the query database smart service.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29325?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 04:06:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a0c2f707-c606-4350-8a13-a95588043695</guid><dc:creator>sonalk</dc:creator><description>Hi Ashwin,&lt;br /&gt;With reference to the XSD code provided by you, try with the code mentioned below : &lt;br /&gt;&amp;lt;xsd:element name=&amp;quot;subCDT&amp;quot; nillable=&amp;quot;true&amp;quot; type=&amp;quot;tns:subCDTType&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;xsd:annotation&amp;gt;&lt;br /&gt;&amp;lt;xsd:appinfo source=&amp;quot;appian.jpa&amp;quot;&amp;gt;@Column(name=&amp;quot;foriegn_composite_key_to_sub&amp;quot;, columnDefinition=&amp;quot;NUMBER(10,0)&amp;quot;) @Id &amp;lt;/xsd:appinfo&amp;gt;&lt;br /&gt;&amp;lt;/xsd:annotation&amp;gt;&lt;br /&gt;&amp;lt;/xsd:element&amp;gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29316?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 22:04:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:83bd47f0-eac9-40ca-8683-43f81e1e9e7d</guid><dc:creator>aswinb608</dc:creator><description>Hi Philb,&lt;br /&gt;&lt;br /&gt;Please apologize me if I understood this wrong from Appian forum as mentioned in the link:&lt;a href="https://forum.appian.com/suite/help/16.1/Database_Schema_Best_Practices.html#Composite_Keys"&gt;forum.appian.com/.../Database_Schema_Best_Practices.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It asks me to denote that key with @Id which I did but seems like what I understood was wrong. Can you please explain the location where I need to put @Id in because I am not following the vague explanation on forum which doesn&amp;#39;t have any examples.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29312?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 21:12:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8703d1da-4284-42e3-b453-330f93af370c</guid><dc:creator>PhilB</dc:creator><description>@jacobc Good point, I forgot about the Query Database Smart Service :)&lt;br /&gt;&lt;br /&gt;@aswinb608 You can&amp;#39;t represent a composite key as you&amp;#39;ve done there. The error message is telling you that you can&amp;#39;t use the @Id annotation in that fashion.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29311?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 20:37:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:35a76c88-406e-499d-bd68-9956e69528f0</guid><dc:creator>aswinb608</dc:creator><description>Hi Philb,&lt;br /&gt;&lt;br /&gt;Due to security constraints on the project I am not able to attach the xsd but I can provide a section of the code in a genralized format where the problem is occuring....here&amp;#39;s the section:&lt;br /&gt;&lt;br /&gt;&amp;lt;xsd:element name=&amp;quot;subCDT&amp;quot; nillable=&amp;quot;true&amp;quot; type=&amp;quot;tns:subCDTType&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;xsd:annotation&amp;gt;&lt;br /&gt;&amp;lt;xsd:appinfo source=&amp;quot;appian.jpa&amp;quot;&amp;gt;@Id @OneToOne @Column(name=&amp;quot;foriegn_composite_key_to_sub&amp;quot;, columnDefinition=&amp;quot;NUMBER(10,0)&amp;quot;)&amp;lt;/xsd:appinfo&amp;gt;&lt;br /&gt;&amp;lt;/xsd:annotation&amp;gt;&lt;br /&gt;&amp;lt;/xsd:element&amp;gt;&lt;br /&gt;&lt;br /&gt;The subCDT has two columns which pairs up to form a composite key and &amp;quot;foriegn_composite_key_to_sub&amp;quot; represents that pair....&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29309?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 20:10:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:eed0386c-bf7a-4cbe-8435-2a06d0013f3e</guid><dc:creator>Jacob Cohen - Project Leader - Macedon Technologies</dc:creator><description>As stated in the documentation, &amp;quot;The Query Database Smart Service can read from and write to tables with composite keys.&amp;quot; You may have to switch to that.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29308?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 20:02:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e51510fb-d4c8-4152-af02-1ecb089809b3</guid><dc:creator>PhilB</dc:creator><description>@ramakg Are you able to have the table owners add a stored procedure to insert to that table? You could then call that instead of doing a direct database write.&lt;br /&gt;&lt;br /&gt;@aswinb608 Are you able to attach your XSD?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29306?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 19:55:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8069bb95-fd9d-4532-b60c-6d8d9a9dd402</guid><dc:creator>aswinb608</dc:creator><description>I am getting an error when declaring additional variables in that cdt with @Id representing foriegn key to that composite key table...see attached...&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/cdt_5F00_error.JPG"&gt;&lt;img src="/cfs-filesystemfile/__key/communityserver-discussions-components-files/11/cdt_5F00_error.JPG" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29305?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 19:45:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0ce330ef-2b70-41b4-82f2-59f4a612012a</guid><dc:creator>ramakg</dc:creator><description>sorry typo. please read done-&amp;gt;dont&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29304?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 19:43:31 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a48fedbc-d56b-4310-b7b1-f5e5075fe215</guid><dc:creator>ramakg</dc:creator><description>The table is not belongs to us (which is created by some other department) and done have much control. But we have to insert the data through the Appian? Do we have any workaround solution?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29303?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 19:33:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3a39c080-24da-45aa-a50c-d7a95f9b43ed</guid><dc:creator>PhilB</dc:creator><description>I think it&amp;#39;s probably fair to say that Appian doesn&amp;#39;t support composite keys.&lt;br /&gt;&lt;br /&gt;What we&amp;#39;ve done in the past is have a view built over the table which adds a new column that provides a unique key per row - but that doesn&amp;#39;t help much if you need to write to the table.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29301?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 19:24:57 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:143f156f-bb49-4ab1-86c1-3400ef12cf4b</guid><dc:creator>Jacob Cohen - Project Leader - Macedon Technologies</dc:creator><description>Here is the documentation on composite keys: &lt;a href="https://forum.appian.com/suite/help/16.1/Database_Schema_Best_Practices.html#Composite_Keys"&gt;forum.appian.com/.../Database_Schema_Best_Practices.html&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi,&lt;br /&gt;I am trying to map a composite key from a different CDT to another one</title><link>https://community.appian.com/thread/29299?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 18:48:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d36ec0fb-ab51-4c11-96d6-7b91e037ef62</guid><dc:creator>ramakg</dc:creator><description>We are also having similar requirement. The database table contains the composite primary key (on 2keys). How to define a composite primary key in cdt?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>