Create more than one primary key in schema? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manoj_Kumar

Hello @kumar_27 

 

Yes, you can create a composite key in AC.

 

Here is an example:

<key internal="true" name="id"> <keyfield xpath="@field1"/> <keyfield xpath="@field2"/> </key>

 

 

3 replies

Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
September 14, 2023

Hello @kumar_27 

 

Yes, you can create a composite key in AC.

 

Here is an example:

<key internal="true" name="id"> <keyfield xpath="@field1"/> <keyfield xpath="@field2"/> </key>

 

 

Manoj     Find me on LinkedIn
ParthaSarathy
Community Advisor
Community Advisor
September 20, 2023

@kumar_27 , Yes you can create a composite primary key by using the above syntax provided. 

In structure, you can see PK symbol as below

 

If field1 & field2 is your composite primary key, and when you insert values for field1 and field2 as a-a, then a-b, b-a, and b-b, it will accept. But when you try to add b-b again, it will throw error '1 record(s) already exist in the database'

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
Kumar_27Author
Level 2
September 22, 2023

@parthasarathy thanks a lot for your clear explanation.

LakshmiPravallika
Community Advisor
Community Advisor
September 14, 2023

Hi @kumar_27 ,

 

If you want , you can create the Combination of Columns what you want as the Primary key which is called as Composite Key in Adobe Campaign.

 

Syntax:

<key name="PrimaryKeyInternalName" internal="true">
<keyfield xpath="@column1"/>
<keyfield xpath="@column2"/>
</key>

 

Please find the documentation for reference:

https://experienceleague.adobe.com/docs/campaign-classic/using/configuring-campaign-classic/schema-reference/elements-attributes/key.html?lang=en

 

Regards,

Pravallika.

 

 

 

Craig_Thonis
Adobe Employee
Adobe Employee
September 14, 2023

Hi Preeth,

 

The short answer to your question is no. However, this is not a product limitation but a standard practice for databases in general.

You can use a combination primary key, combining two fields to create a unique key. You can also have foreign keys, which are primary keys from other tables linked to your table.

I recommend walking through the developer documentation section in the Campaign documentation before diving into any schema changes. Additionally, if you are new to database management/development, then I would recommend leveraging your database's website documentation as all databases have their own syntaxes and nuances that can greatly impact performance.