HI ALL
why we need to define autopk=true in data schema in ACC
WHAT WILL HAppEN IF WE DONT define AUTOPK=true in data schema
if we seT BELOW CODE IT WILL DECLARE PRIAMRY KEY
THEN AUTOPK=true in data schema will it also declare primary key?just confused with the difference in these two
key name="PrimaryKey" internal="true"> <keyfield xpath="@name"/> </key>
Solved! Go to Solution.
Views
Replies
Total Likes
@jefrii ,
Schema requires an unique attribute for each data row (records), which is primary key.
If you feel you don't have a dedicated attribute as a primary key in your schema, and to insert a record define autopk="true" . This will create a attribute "id" and auto-sequence for it. So whenever a new record gets inserted, the Primary key (@id) will keeps on incrementing which will be unique.
If your schema have dedicated attribute as primary key, you don't have to use autopk and can use the primary key definition syntax as you mentioned in question part.
<key name="PrimaryKey" internal="true"> <keyfield xpath="@name"/> </key>
In this case, if you try to insert 2 records with same "name" it will throw an error stating 'duplicate in primary key'
@jefrii ,
Schema requires an unique attribute for each data row (records), which is primary key.
If you feel you don't have a dedicated attribute as a primary key in your schema, and to insert a record define autopk="true" . This will create a attribute "id" and auto-sequence for it. So whenever a new record gets inserted, the Primary key (@id) will keeps on incrementing which will be unique.
If your schema have dedicated attribute as primary key, you don't have to use autopk and can use the primary key definition syntax as you mentioned in question part.
<key name="PrimaryKey" internal="true"> <keyfield xpath="@name"/> </key>
In this case, if you try to insert 2 records with same "name" it will throw an error stating 'duplicate in primary key'
Hi @jefrii ,
The attribute autopk="true" is defined in the element tag of the Schema only if we require the auto incremental Primary Key sequence like 1,2,3 and so on..
Example : We can consider nms:recipient OOTB schema, which has autopk="true" in the schema tag, the below column and the Primary key syntax comes up in the Preview Tab even though it was not added manually in the Edit Tab of the Schema. Below is the Sample Code which gets automatically added in the Preview Tab if autopk is defined,
<attribute desc="Internal primary key" label="Primary key" name="id" sqlname="iRecipientId"
type="long"/>
<key internal="true" name="id">
<keyfield xpath="@id"/>
</key>
It is mandatory to define the Primary Key for any Schema in Adobe Campaign but It is not mandatory to define autopk="true" in the Schema(autopk is used as per our requirements only), If the Uniqueness is based on an attribute or combination of attributes then the Primary key should be defined on them.
Example: In Schema called cus:product , the 2 columns product_id and product_name are having uniqueness, then we need to define the Primary Key in edit Tab of our Schema as below:
<key internal="true" name="PK_product">
<keyfield xpath="@product_id"/>
<keyfield xpath="@product_name"/>
</key>
PFA Documentation Links for reference
Regards,
Pravallika.