Can I define two primary keys in a database table & why?ExactTarget - How to post a record to a data extension that has no primary key?Can you use two DE within the same AmpscriptingHow do you construct a REST API URI with multiple primary keys?Upserting Duplicates despite three part primary keyshow to append one data extension data to other sendable data extension?Trying to combine two DE and getting violation of primary key errorViolation of PRIMARY KEY constraint. Cannot insert duplicate keyData Extension synchronous Rest API where there are only primary keysImporting data with primary key duplicatesMarketing Cloud - Adding additional Primary Keys to a Existing Data Extension

Policemen catch thieves

Change the boot order with no option in UEFI settings

Impossible darts scores

Change CPU MHz from Registry

What is the legal status of travelling with (unprescribed) methadone in your carry-on?

How to split an equation over two lines?

Hot coffee brewing solutions for deep woods camping

Could Sauron have read Tom Bombadil's mind if Tom had held the Palantir?

Fedora boot screen shows both Fedora logo and Lenovo logo. Why and How?

Analog is Obtuse!

Do hotel cleaning personnel have any benefit from leaving empty bottles in the room as opposed to returning them to the store?

Can the negators "jamais, rien, personne, plus, ni, aucun" be used in a single sentence?

Is this one of the engines from the 9/11 aircraft?

Why do some games show lights shine through walls?

Is adding a new player (or players) a DM decision, or a group decision?

Abel-Jacobi map on symmetric product of genus 4 curve

Are there any vegetarian astronauts?

What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?

Why is the voltage measurement of this circuit different when the switch is on?

Can White Castle?

How can I repair scratches on a painted French door?

Peace Arch without exiting USA

Plotting with different color for a single curve

Why does the numerical solution of an ODE move away from an unstable equilibrium?



Can I define two primary keys in a database table & why?


ExactTarget - How to post a record to a data extension that has no primary key?Can you use two DE within the same AmpscriptingHow do you construct a REST API URI with multiple primary keys?Upserting Duplicates despite three part primary keyshow to append one data extension data to other sendable data extension?Trying to combine two DE and getting violation of primary key errorViolation of PRIMARY KEY constraint. Cannot insert duplicate keyData Extension synchronous Rest API where there are only primary keysImporting data with primary key duplicatesMarketing Cloud - Adding additional Primary Keys to a Existing Data Extension






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















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.










share|improve this question
























  • Is this question related to Salesforce Marketing Cloud?

    – David Reed
    Jun 15 at 11:46











  • yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

    – ASHISH
    Jun 15 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 at 12:30

















3















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.










share|improve this question
























  • Is this question related to Salesforce Marketing Cloud?

    – David Reed
    Jun 15 at 11:46











  • yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

    – ASHISH
    Jun 15 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 at 12:30













3












3








3








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.










share|improve this question
















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.







marketing-cloud query sql contactbuilder






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 15 at 12:19









David Reed

45.5k8 gold badges26 silver badges65 bronze badges




45.5k8 gold badges26 silver badges65 bronze badges










asked Jun 15 at 8:02









ASHISHASHISH

31113 bronze badges




31113 bronze badges












  • Is this question related to Salesforce Marketing Cloud?

    – David Reed
    Jun 15 at 11:46











  • yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

    – ASHISH
    Jun 15 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 at 12:30

















  • Is this question related to Salesforce Marketing Cloud?

    – David Reed
    Jun 15 at 11:46











  • yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

    – ASHISH
    Jun 15 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 at 12:30
















Is this question related to Salesforce Marketing Cloud?

– David Reed
Jun 15 at 11:46





Is this question related to Salesforce Marketing Cloud?

– David Reed
Jun 15 at 11:46













yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

– ASHISH
Jun 15 at 12:16





yes. This is related to contact builder in marketing cloud. sql is used to create data extensions.

– ASHISH
Jun 15 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 at 12:30





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 at 12:30










2 Answers
2






active

oldest

votes


















3














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 .






share|improve this answer








New contributor



diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2





    SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

    – Adam Spriggs
    Jun 16 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 at 2:28


















0














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:



SELECT
field1
field2
...
FROM DE1
INNER JOIN DE2
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! :-)






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f266091%2fcan-i-define-two-primary-keys-in-a-database-table-why%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    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 .






    share|improve this answer








    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.














    • 2





      SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

      – Adam Spriggs
      Jun 16 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 at 2:28















    3














    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 .






    share|improve this answer








    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.














    • 2





      SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

      – Adam Spriggs
      Jun 16 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 at 2:28













    3












    3








    3







    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 .






    share|improve this answer








    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.









    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 .







    share|improve this answer








    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.








    share|improve this answer



    share|improve this answer






    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.








    answered Jun 15 at 8:16









    diamonddiamond

    621 bronze badge




    621 bronze badge




    New contributor



    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




    New contributor




    diamond is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.









    • 2





      SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

      – Adam Spriggs
      Jun 16 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 at 2:28












    • 2





      SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

      – Adam Spriggs
      Jun 16 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 at 2:28







    2




    2





    SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

    – Adam Spriggs
    Jun 16 at 11:38





    SFMC Users cannot create indexes on Data Extensions without some sort of engagement with Salesforce.

    – Adam Spriggs
    Jun 16 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 at 2:28





    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 at 2:28













    0














    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:



    SELECT
    field1
    field2
    ...
    FROM DE1
    INNER JOIN DE2
    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! :-)






    share|improve this answer



























      0














      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:



      SELECT
      field1
      field2
      ...
      FROM DE1
      INNER JOIN DE2
      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! :-)






      share|improve this answer

























        0












        0








        0







        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:



        SELECT
        field1
        field2
        ...
        FROM DE1
        INNER JOIN DE2
        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! :-)






        share|improve this answer













        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:



        SELECT
        field1
        field2
        ...
        FROM DE1
        INNER JOIN DE2
        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! :-)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 16 at 14:44









        alamoalamo

        1166 bronze badges




        1166 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f266091%2fcan-i-define-two-primary-keys-in-a-database-table-why%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form