function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pjcocopjcoco 

Circular Many-to-Many Reference

Hello,

 

I'm looking into the possiblity of creating Circular Many-To-Many relationships with Salesforce. For instance if I would like to incorporate Users following other Users in some sort of Feed. Not like chatter, it's actually for use in Database.com.

 

Thanks in advance.

TheIntegratorTheIntegrator

I generally create this using an additional object that by terminology is called a junction object. This object has 2 lookups to either 2 objects or the same object.

 

For example, Users following Users

Junction_Object__c

Follower__c Lookup(User)

Following__c Lookup(User)

 

Hope that helps

pjcocopjcoco

I was afraid this was going to be the solution. I know the principle of a Junction object, and normally you would do this with Master-Detail relationships, if for example you would delete the User object in question, the junction object won't be deleted with this lookup relationship, and you would have useless data.

 

Unless you write trigger logic, or possibly use workflows.

 

I find this to be quite a shortcoming for the Database.com product, you wouldn't have this problem with normal (relational) database solutions. Sure on the Salesforce platform you can't do this either, but perhaps it's because you don't see this particular use-case that much, however in pure databases, and definitely in web-apps and mobile-apps i think you'll find this more and more.