Understanding the nature of relationships

Ah, probably the headline got your attention! However, this is not a blog about psychology or human relationships. They are not that predictable after all. I want to get your attention to "predictable" types of relationships in Force.com, namely the types of queries that you can use and get results by using SOQL using relationships and how to use them effectively.

For those of you who are getting familiar with the platform or would like to have a deeper look at semantics of the queries that are possible in Force.com, this blog is for you. Just like some of you, I come from the relational and ORM world prior to joining Salesforce.com and started developing on the Force.com platform. As a result, just like some of you, I was very versed in creating relationships by hand in tables, how to use foreign keys, optimization, what kind of query support there may exist in the ORM world, whether it is EJBs, Hibernate,  etc.

In Force.com, the query language for the data model is SOQL. It is an object oriented cousin of SQL. Thus, understanding the similarities and differences between SQL and SOQL does help to be more effective in the platform.

SOQL is based on the data model provided in Force.com where the developer does not have to do the actual mapping between the conceptual model of an app to a physical table structures, optimization, mapping of relationships, etc. The relationships and path navigation between objects is a first class concept in queries. 

As a result, here is an article that may help you. It also highlights some features that may be missed otherwise.

If you have started in Force.com because you are interested in Chatter, this article will also help you with the basics of the query semantics and usage of relationships in the platform. The majority of the activity you will perform with Chatter is via understanding the objects, relationships and how to get feed data for your app and how well you use relationships using SOQL. Thus, as a prerequisite, understanding the basics will help you as different types of relationships, the type of joins available to you (such as outer and inner joins in a world where path expressions are a given!) and how they may stack up with respect to SQL or the paradigms you are familiar with.

If you have additional points/feedback for a later version of this article, please do not hesitate to include comments so that we can improve it.

Leave your comments...

Understanding the nature of relationships