Salesforce is the leading cloud vendor today due to an amazing range of services and offerings that has gained immense popularity during the last few years. In this post, we will majorly focus on the database concepts in Salesforce.com. We will check how Salesforce is connected to multiple relational database systems available in the technical marketplace.
All databases could be similar to the objective but they are different in terms of naming and conventions. Here, we will see how can we create the data sources and how to establish or maintain a relationship among multiple data objects.
A Database in Salesforce is defined as the organized collection of objects where each object contains some information. Data is stored in the form of database tables for people, things, contacts etc that are important for any project in the future. Each database has a set of certain rows and columns where information is stored in the form of fields and records. Take an example of Employee table where information is stored in the form of different fields like employee ID, salary, designation, name, contact details, etc. Here, Employee is an object and all related information is taken as fields.
Apart from these three objects, there are a few objects that are available in API as well and we could access authorized objects only. The access to an object can be defined in multiple ways like user permissions, user ID, object configuration, access settings, data model, or any other factor that could be related to an object. Most of the objects from API have read-write access and a few of them are assigned read-only permissions.
Relationships in Salesforce are used to connect different objects together. There are multiple relationships that could be defined for the Salesforce on the child object. The child object could have complete access to the object defined in the parent section based on the relationship and permissions defined.
In this type of relationship, there is only one parent object and multiple child objects. For example, there are a number of metro cities in a country. It is further divided into four major categories as shown above in the hierarchy diagram –
Let us discuss each of them one by one in detail below –
Here, we have one parent object and multiple child objects. For this type of relationship, you need to keep the following facts in mind –
This is possible to define the master-detail relationships on two or more custom objects. The relationship can be defined among one standard and one custom object but the custom object could not be fixed at the detail side. And the data for custom objects is displayed on the page layout. Keep in mind that master-detail relationships are not applicable to the object where User or Lead objects are defined as the master.
Look up Relationship:
This is one more category of one-to-many relationship but two objects will not put any effect on deletion or security. In this case,
In this type of relationship, the object is self-referred. For example, add-on card onto your credit card.
It is very much similar to the lookup relationship but it can be defined for user objects only. Further, you can use lookup fields to connect multiple users together. User objects may refer to themselves either directly or indirectly.
This type of relationship is used to model many-to-many relationships between any two objects. For many-to-many relationships, each record of one object could be further linked to multiple records from other objects and vice versa. In this case, we should create the junction object to help in creating many-to-many relationship fields and they are further connected to custom objects.
What is a Junction Object?
This object is needed to create many-to-many relationships that support two type of relationships master-detail and the lookup relationships. They both are one-to-many relationships and to define many-to-many relationships in that case, we need a Junction Object.
How are many-to-many and one-to-many relationships different?
A one-to-many relationship is always defined on master-detail or look up relationships while many-to-many relationships are defined using two master objects. For many-to-many relationships, each record of one object could be further linked to multiple records from other objects and vice versa. Look up is one-to-many type relationship where two objects are connected but the child object will not get impacted once parent object is deleted. At the same time, in the case of a normal one-to-many relationship, when a master record is deleted, the child will also be deleted automatically.
Normal Database (Excel) vs. Relational Database (Salesforce.com)
In case of normal databases, there is duplicate information can be used several times. But in the case of relational databases, there is always unique information is stored one instance can be used to refer multiple fields together. Generating a report in Excel is tedious and when it comes to Salesforce, reporting features are just overwhelming and enjoyed by developers.
Primary key vs. Foreign Key in the Salesforce database (Conceptual Knowledge)
A Primary key is defined as the column or a set of columns that can identify each record in the table uniquely. When a primary key is defined with the help of multiple columns, data from each row is assessed to check the uniqueness. Every time a column is defined as the unique key, there are some constraints to follow like column value should not be NULL and the data would always be UNIQUE.
At the same time, a Foreign key is defined as the column or a set of columns that is referring to the primary key of another table. This is not necessary that foreign key will always follow the primary key but the basic idea behind foreign key is that any column that is unique to identify that record. When we are learning the Salesforce as a database, this is necessary to get the basic knowledge of SOQL too.
SOQL is Salesforce Object Query Language that is highly similar to SQL (Structured Query Language). With the help of SOQL, you can always search the organizational data wisely. It can be combined with APEX, Visualforce, or Force.com IDE too. While writing a query using SOQL, you should use SELECT command and a lot of other conditions too. Here, is the basic syntax how to write SOQL query in Salesforce using SELECT command –
Now let us learn when should you use SOQL. The SOQL can be used when you have the basic idea of objects and the related data. It can be used to retrieve data from one or multiple objects that are connected together based on requirements. It helps in getting the total count and sort queries as well. Further, it can be combined with SOSL (Salesforce Object Search Language) to search the organizational data when they are not sure on objects.
SOSL is programmed in such a way to work on the basis of the search index. To improve the performance of searching, you should combine SOQL and SOSL together because searching work is done better by SOSL as compared to the SOQL.
That’s all for the day. You have learned a lot about the Salesforce database and related concepts too. To know more, you should join the Salesforce certification training program to get the hands-on expertize on database concepts.
JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.
Course for testing
Receive Latest Materials and Offers on Salesforce Course