Difference between one-to-one left and right relationships

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Umbromancer
    Junior Member
    • Apr 2022
    • 5

    Difference between one-to-one left and right relationships

    Hi,

    I've searched the forums and read the docs and can't figure out the difference. I've implemented two identical relations and found no practical difference between the right or left definition. Is the distinction meant to be a semantic help for hard to conceptualize cases? Can someone shed light on this?

    Tx you
  • bandtank
    Active Community Member
    • Mar 2017
    • 379

    #2
    I have the same question. In practice, I arbitrarily choose left because I can't perceive a difference, but I am curious to know if I'm missing something.

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #3
      Hi,
      https://github.com/espocrm/espocrm/b...s/RDB.php#L623

      if you create for sample : on Account, you create a one-to-one right to Document.
      then you have too the relation between Document one-to-one left to account.

      So only one Account can have the Document. : previousForeignEntity->set($foreignKey, null);
      Or in other word, this document can have only one Account

      It's perfect for a basic sample : a car can have many "proprietary in the past" .. but who is the last/current ?
      a patient can have many docteur, but who is the current generalist ?

      It's my understand
      Last edited by item; 04-16-2022, 07:48 PM.
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment

      • Umbromancer
        Junior Member
        • Apr 2022
        • 5

        #4
        Hi,

        Yes, I see that if I create on the Account entity a one-to-one right to Document, then on the Document Entity it will exhibit a one-to-one left to Account. And, in the same manner, if instead it is created on the Account entity a one-to-one left to Document , then the Document Entity will exhibit a one-to-one right to Account.

        But, both relationships can be used in all panels except Bottom Panels ((it makes sense they are not available for Bottom Panels). And both relationships seem to behave the same way whether they are right or left and whether they are on Account or Document layouts (I've tried all of this).

        Since it is expected that there is some behavioral difference in the system between both types of one-to-one relationships, I wonder what third aspect we are missing here, or this semantic only seeks to aid customization? Perhaps these relationships work in a different way when there are permissions involved, I don't know. I just guessed this should be a common doubt, so decided to ask.

        txs

        Comment

        • telecastg
          Active Community Member
          • Jun 2018
          • 907

          #5
          The designation of "Right" or "Left" in a One-to-One link determines which table has a column that contains the link to the other entity.

          For example, if you have Entity A - One to One Right - Entity B, the table entity_a will have a column entity_b_id that contains the value of the id of the single Entity B record to which Entity A is linked.

          If you have Entity A - One to One Left - Entity B, the table entity_b will have a column entity_a_id that contains the value of the id of the single Entity A record to which Entity B is linked.
          Last edited by telecastg; 04-19-2022, 05:31 PM.

          Comment

          • Umbromancer
            Junior Member
            • Apr 2022
            • 5

            #6
            Thank you telecastg !

            Comment


            • telecastg
              telecastg commented
              Editing a comment
              You're very welcome
          • marcusquinn
            Senior Member
            • Jan 2021
            • 133

            #7
            IMHO, assuming I'm correct, it would be helpful to name them:
            - One-to-One Parent on Left
            - One-to-One Parent on Right

            Parent & Child referring to the hierarchy of ownership that the Entity this relationship is being created for. Left & Right alone don't really make this obvious.

            I think the only significance is in then building data ownership trees, and maybe left-join query efficiencies, so some big searches will be faster is the structure is correct.

            Comment

            Working...