Hi All,
I am working on version 18.1.
I have a few queries around Primary Key in Appian's MY SQL database:
1. In my MySQL database, if I want to create two columns as primary key i.e. if I want to create a composite key rather than making just one column as a primary key then how can I do that as in my data type Appian allows to create only one column as primary key though in XSD we can add two columns as primary key using @Id annotation. So I would like to know how can I achieve this or I can only create one column as primary key.
2. Also would like to know in which scenario do I get Unique Key Constraint violated error.
Thanks in advance!!
Discussion posts and replies are publicly visible
Hi paragk998 Thanx for replying!! My scenario requires that I need to make a composite key the primary key i.e. need to make two columns as primary key.
Also when I open the data type, Appian allows to create only one column as primary key though in XSD (using @Id annotation) as well as in the MySQL table structure we can add two columns as primary key (as shown below).
Any suggestions...
Hi komalc
in that case create CDT from xsd. or database table
hope this will help.
Hi paragk998
Thanx for replying!!
What I am trying to do is: I am modifying my existing CDT and uploading a new version of it wherein I want to make another existing column as primary key.
The screen shot of table is (which is correct):
Below is the screen shot with the error which I get when I try to upload new version of my CDT wherein I am making an existing column primary key with @Id annotation
Am I missing anything, any suggestion...?
Composite keys are, in effect, not supported. The options for dealing with composite keys are documented here: docs.appian.com/.../Database_Schema_Best_Practices.html
PFB the xsd:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:com:appian:types:MYAPP" targetNamespace="urn:com:appian:types:MYAPP"> <xsd:complexType name="MYAPP_Security"> <xsd:annotation> <xsd:appinfo source="appian.jpa"> @Table(name="MYAPP_SECURITY") </xsd:appinfo> </xsd:annotation> <xsd:sequence> <xsd:element name="id" nillable="true" type="xsd:int"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Id</xsd:appinfo> </xsd:annotation> </xsd:element> <xsd:element name="firstName" nillable="true" type="xsd:string"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Id @Column(length=255)</xsd:appinfo> </xsd:annotation> </xsd:element> <xsd:element name="lastName" nillable="true" type="xsd:string"> <xsd:annotation> <xsd:appinfo source="appian.jpa">@Column(length=255)</xsd:appinfo> </xsd:annotation> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:schema>
Screen shot of Table structure: