Results 1 to 5 of 5

Thread: What's the difference between relationship and related fields

  1. #1
    blasher Guest

    Question What's the difference between relationship and related fields

    what is the difference between defining relationship between two modules and creating a related field in one of the modules?

  2. #2
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,491

    Default Re: What's the difference between relationship and related fields

    The difference is several things

    First at the database level, a relationship is kept in a join table, whereas the related field is kept in one or two fields within the module you create it is.

    at the code level, a relationship is available to both modules, if you create a relationship between say Accounts and ProjectTasks both modules know about it and can display it (either as a subpanel or a field), whereas the relationship field is only available to the module you create it in. The other module has no idea at all that it exists.

    The relationship field came out a long time ago and was the first attempt at adding the ability to relate modules to one another in custom ways. It is still there as a legcy thing. It is my opion that you should never use it anymore. Anything that you can do with a relate field you can do with a relationship and the relationship is better code.
    Kenneth Brill - Help Forum Moderator

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

    Look for these SugarCRM Tools
    SweetDBAdmin 1.9 - Intuitive web interface for your SugarCRM 6.4+ database (MySQL, SQL Server, Oracle and DB2)
    SweetUndelete 1.0 - The very best Undelete module for SugarCRM 6.4+. Allows admins and Users to undelete records and relationships
    SweetTinyMCEUpgrade - Upgrades your SugarCRM's TinyMCE installation to 3.5.8 (currently it's 3.4.4)
    SweetActivities 0.8 beta - An example of how to create a View on Calls, Meetings, Tasks and Emails so they can be viewed and reported on as one module. NOT FOR MSSQL YET



  3. #3
    blasher Guest

    Default Re: What's the difference between relationship and related fields

    @brill sorry for the delayed response. i never received an email that you had responded and just happened upon this while searching for some other info.

    anyways, thanks for the info. i've been playing with this stuff a bit lately and have now seen the difference, however, i am very interested in your response. i like the way you described the "relationship" as being "available to both modules", and it is basically the same explanation that i gave to a colleague.

    also, i've figured out how to display a "relationship" as a subpanel, but haven't yet figured out how to display a "relationship" as a "field" as you suggest is possible. i will try to figure it out on my own, but if you get this any time soon and are feeling generous, a quick tip would be greatly appreciated.

    since i am new to working with sugar, and am knee-deep in a system integration project using sugar as the development platform, i've been mostly concerned so far with getting my modules set up and data imported. i haven't gotten too much into the code side of it, but will be knee-deep in that aspect very shortly. i'm anxious to delve into the differences in the code you speak of.

    i've got some questions regarding how sugar handles "relationships" and "relate fields" during import. unless i am missing something, it appears that sugar can only match things up on the "name" field. i've got several custom modules where "name" is not really an appropriate field.

    don't laugh, but, for example, i've got a module called "smoking history" which has fields "client_id, smoke type, number of packs per day, year started, and year ended". this is of course related to another custom module called "clients". when i import data for these modules, the relationship isn't maintained because the "client_id" in the smoking history table doesn't match the "name" in the client table. no biggy. i can post-process the data to create the relationship similar to the way sugar "attempts" to create the relationships.

    is there some way to specify to sugar, which fields (other than name) that it should be looking at to establish a relationship?

  4. #4
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,491

    Default Re: What's the difference between relationship and related fields

    Quote Originally Posted by blasher View Post
    @brill sorry for the delayed response. i never received an email that you had responded and just happened upon this while searching for some other info.

    anyways, thanks for the info. i've been playing with this stuff a bit lately and have now seen the difference, however, i am very interested in your response. i like the way you described the "relationship" as being "available to both modules", and it is basically the same explanation that i gave to a colleague.

    also, i've figured out how to display a "relationship" as a subpanel, but haven't yet figured out how to display a "relationship" as a "field" as you suggest is possible. i will try to figure it out on my own, but if you get this any time soon and are feeling generous, a quick tip would be greatly appreciated.
    If you have a one-to-many relationship, the 'one' side is always displayed as a field on the module just as the 'many' side is shown as a subpanel. Whereas a 'relate' field is only ever shown as a field in the module where is it placed.

    Just to be complete a one-to-one relationship would be shown as a field in both modules and a many-to-many relationship would be shown as a subpanel on both sides.
    Quote Originally Posted by blasher View Post
    since i am new to working with sugar, and am knee-deep in a system integration project using sugar as the development platform, i've been mostly concerned so far with getting my modules set up and data imported. i haven't gotten too much into the code side of it, but will be knee-deep in that aspect very shortly. i'm anxious to delve into the differences in the code you speak of.

    i've got some questions regarding how sugar handles "relationships" and "relate fields" during import. unless i am missing something, it appears that sugar can only match things up on the "name" field. i've got several custom modules where "name" is not really an appropriate field.
    Yes that is correct and is something that is being worked on, but for now the name field is the 'main' field. Most times if I have a problem with it I just reuse the name field as something unique even if its not called name. Sometimes I have copied data from one or more fields into name "on save" to make a unique field that I can reference even if I do not show it on any of the views.
    Quote Originally Posted by blasher View Post
    don't laugh, but, for example, i've got a module called "smoking history" which has fields "client_id, smoke type, number of packs per day, year started, and year ended". this is of course related to another custom module called "clients". when i import data for these modules, the relationship isn't maintained because the "client_id" in the smoking history table doesn't match the "name" in the client table. no biggy. i can post-process the data to create the relationship similar to the way sugar "attempts" to create the relationships.

    is there some way to specify to sugar, which fields (other than name) that it should be looking at to establish a relationship?
    None at all that I know of. My one peice of advice here would be to work on getting rid of the relate fields, they are nothing but trouble. It might take a bit of scripting at this point but it will be worth it even if you only get rod of one a month or whatever.
    Kenneth Brill - Help Forum Moderator

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

    Look for these SugarCRM Tools
    SweetDBAdmin 1.9 - Intuitive web interface for your SugarCRM 6.4+ database (MySQL, SQL Server, Oracle and DB2)
    SweetUndelete 1.0 - The very best Undelete module for SugarCRM 6.4+. Allows admins and Users to undelete records and relationships
    SweetTinyMCEUpgrade - Upgrades your SugarCRM's TinyMCE installation to 3.5.8 (currently it's 3.4.4)
    SweetActivities 0.8 beta - An example of how to create a View on Calls, Meetings, Tasks and Emails so they can be viewed and reported on as one module. NOT FOR MSSQL YET



  5. #5
    blasher Guest

    Default Re: What's the difference between relationship and related fields

    THANKS for the clarifications!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2012-12-05, 04:44 PM
  2. What is the difference of Labels vs. Fields
    By loren.hale in forum Help
    Replies: 0
    Last Post: 2011-12-01, 03:05 AM
  3. What is the difference of Labels vs. Fields
    By loren.hale in forum General Discussion
    Replies: 0
    Last Post: 2011-12-01, 03:01 AM
  4. Storing fields related to a relationship
    By tickletoe in forum Help
    Replies: 3
    Last Post: 2011-03-17, 09:44 PM
  5. Replies: 0
    Last Post: 2009-02-12, 06:02 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •