Relationship defines how different objects are associated or linked to each other. In Force.com platform, you set up relationships by creating custom relationship fields on an object. While adding new fields to the object, you select the appropriate data type. Master-Detail relationship or Lookup relationship.
Happy cloud computing using Salesforce!
Master-Detail Relationship
This type of field creates a parent-child relationship between objects. This relationship field serves in allowing us to achieve many-to-one and many-to-many relationship between objects.
When you are adding a custom field of this type on an object, the object you are adding the field to works as child object. The other object that you select as 'Related To' is the parent. Hence you are creating many-to-one relationship. The child object record's ownership, sharing and security is determined by the parent object record's setting. In fact, the child object doesn't have a owner field. In other words, the child records are owned by the owner of the parent record and also when the parent record is deleted all its child records are deleted as well.
Many-to-Many relationship can also be achieved using the same relationship field. But we need to understand where this field resides. To achieve many-to-many relationship between two objects we create a custom object called junction object. This junction object is basically like intersection table between two tables in RDBMS. We create two master-detail relationship fields in the junction object to link with the objects for which we want to create many-to-many relationship.
This type of field creates relationship between two objects in a simple form. Using this you can even link an object with itself. Unlike master-detail relationship, this one is loosely coupled and no cascading deletion. In other words, deletion of records in any object has no effect on the other linked object records. The ownership is maintained independently as well.
So, that is how the relationships between the objects are achieved. Go ahead and try out some.
Many-to-Many relationship can also be achieved using the same relationship field. But we need to understand where this field resides. To achieve many-to-many relationship between two objects we create a custom object called junction object. This junction object is basically like intersection table between two tables in RDBMS. We create two master-detail relationship fields in the junction object to link with the objects for which we want to create many-to-many relationship.
Lookup Relationship
This type of field creates relationship between two objects in a simple form. Using this you can even link an object with itself. Unlike master-detail relationship, this one is loosely coupled and no cascading deletion. In other words, deletion of records in any object has no effect on the other linked object records. The ownership is maintained independently as well.
So, that is how the relationships between the objects are achieved. Go ahead and try out some.
Happy cloud computing using Salesforce!
No comments:
Post a Comment