Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I checked 'Account Name' field in Contact object. It appeared as a Lookup(Account). But when I deleted that account, contact also got deleted which tells me it is a master-detail relation. Can anyone explain me the proper way to explain the relationship between account and contact?

share|improve this question
add comment

5 Answers

up vote 4 down vote accepted

There are four different kind of relationships in the force.com platform.

But I like to categorize them in a slightly different way than the help pages:

  • Lookup
  • Master-Detail
  • Hierarchy
  • Standard relationships

There are lot's of help topics and articles on Lookup and Master-Detail, such as the relationship overview and the relationship considerations topics in help. I don't like including Many-to-Many in this kind of discussion because, for all intents and purposes M:M is just an implementation of two M-D relationships (by strict reading of the docs), or possibly two lookup relationships or a mix of the two.

To dispense quickly with hierarchy relationships, these are a special lookup self-join relationship on the User object. Read up on those on your own. :-)

So let me talk about my own invented fourth category.

Standard Relationships

If we (salesforce.com) provide you with a relationship between two objects, that is a standard relationship. Not lookup, not master-detail. Why do I bother providing this fourth category? Because it is the easiest way to stop people trying to categorize them as either lookup or master-detail when they often share characteristics of both. When you approach working with any standard relationship the question you really need to answer is, "how does this standard relationship behave." Frequently standard relationships have characteristics that you just can't do with a custom relationship. Ever tried to make a custom relationship polymorphic? Go ahead...give it a try. You will fail. But there are many examples of polymorphic standard relationships.

I like to categorize these in their own separate place independent of lookup/master-detail. In fact, anything standard follows the same rule: it behaves exactly the way that salesforce.com wants it to behave to fit the particular purpose of that standard thing.

In my opinion, the Account-Contact relationship is a perfect justification for this fourth category: it is a little like lookup, a little like Master-Detail, but fundamentally behaves the way it does because we decided it should.

That might not be the "proper" way, as you ask, but it is the one that makes the most sense to me.

share|improve this answer
    
Couldn't have got a better explanation. Thanks @peter –  MnZ Apr 16 at 7:48
add comment

Contacts and Accounts have a lookup relationship but this relationship has a property called CascadeDelete set to true. This is why the contact is deleted when the parent object is deleted. enter image description here.

share|improve this answer
    
Is CascaDedelete available for custom object lookup relationships? I hope its not a silly question, I'm a beginner :) –  MnZ Feb 24 at 13:53
    
No, you cannot set that property in a custom lookup relationship. –  PepeFloyd Feb 24 at 15:53
1  
Actually, cascade delete is an option in a custom lookup relationship, but you must contact support to enable this feature. There are important considerations around cascading a lookup relationship in that a user might cascade a delete to child records that they normally wouldn't have access to even view. Please read the help topics on relationships for more about this. –  Peter Feb 24 at 17:10
    
@Peter Just a random question...Is it mentioned on documentations to contact support to enable some feature that are initially disabled? –  MnZ Apr 16 at 7:56
add comment

Account and contact have a lookup relationship. It is lookup because you can create a contact without account. However it behaves weird –like master detail in business logics – when you create a contact with account and you delete that account then contact will be also deleted.

But it documentation you can find that this is a lookup relationship.

share|improve this answer
add comment

Account and Contact behaves as master-detail but on UI it is a look-up relationship. This is because of business implementation.

Account comes from Opportunity. Suppose you Sale some product. You reach to a person and he fixed some deals with us, By this It becomes an Opportunity. Now that Opportunity purchased some products with you organization. Now he becomes an Account. After that Account reference some contacts with whom your organization can process deal. Now those reference are your organization Contact.

In this case if that Account is no more purchasing products and can not continue with your organization. In that case you delete that account and it makes sense that their related contacts must be deleted. That is why this happens.

Contact without Account as a parent are private and cannot be seen by other users in an organization. Because they are your personal contact persons like you have in your cell phone.

share|improve this answer
add comment

Just to add, another thing where you might get confused w.r.t. account and contact is - if you change the owner of Account record, Contact OwnerId changes. However, when you do the same via code, you have to manually change the Contact owner. So, as everyone said, it is a lookup but internally works like master details.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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