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?
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:
- 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.
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.
Account and contact behaves as master detail in business logics but on UI it is a lookup relationship. Let me explain you a bit more.
You can create a contact without filling account i.e it shows that there is a lookup relationship between account and contact.
If you have created a contact with account and you delete that account then contact will be deleted, this shows that it is in Master-Detail relationship. This is a standard behavior.
So we can say it in both ways, but it documentation it is a lookup relationship.
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.
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.
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.
Account and contact have a custom lookup relationship with the cascade delete option on.
You could create you own custom lookup relationship by openning a case to the support.
Check this knowledge article for more information.