Expand my Community achievements bar.

SOLVED

Create more than one primary key in schema?

Avatar

Level 2

I am new one to adobe campaign classic it is possible to create more than one primary key in custom schema? 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Community Advisor

@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

ParthaSarathy_0-1695210942554.png

 

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'

Avatar

Community Advisor

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-r...

 

Regards,

Pravallika.

 

 

 

Avatar

Employee Advisor

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.