In relational databases we can only define one primary key. Is it possible to define two primary keys, probably one is primary and other is secondary key and can be joined on any of the two fields.

  • Is this question related to Salesforce Marketing Cloud? – David Reed Jun 15 '19 at 11:46
  • yes. This is related to contact builder in marketing cloud. sql is used to create data extensions. – ASHISH Jun 15 '19 at 12:16
  • I've added those relevant tags to the question. Generic relational database questions sometimes are closed as off-topic; it's helpful to make the context clear. – David Reed Jun 15 '19 at 12:30

Yes , we can only define one primary key but you can define unique indexes in your table which can also work like primary key in that case they should have unique values .

| improve this answer | |
  • 2
    SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce. – Adam Spriggs Jun 16 '19 at 11:38
  • This answer seems misleading to me. You can define multiple primary keys that act as a single composite key, so saying you can only define a single primary key but can include unique indexes doesn't seem entirely accurate. – Jason Hanshaw Jun 17 '19 at 2:28

Could you tell a bit more about your goal? That might help to give you the best answer. More than one road leads to Rome after all. :-)

You could have unique indexes set up by Salesforce, but these may require Salesforce Services (at a fee), although you can also try to initiate a support ticket. I'm not sure if they would handle that now.

Another - perhaps easier - work around is to work with two data extensions:

  1. DE1: Primary key + any other information
  2. DE2: Primary key (as a look up to DE1) + your "secondary key"

Then you could write a (SQL) Query Activity. Something like:

    DE1.PrimaryKey on DE2.PrimaryKey

Or use a third party tool like DESelect if you don't like writing SQL.

Let me know if this helps! :-)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.