Salesforce objects, fields and relationships:
1. Objects logically correspond to database tables in a relational database.
Fields of an object is similar in concept to column in relational database.
2. Objects can be standard or custom. Standard are objects are predefined by
Salesforce like Accounts, Case, Contact etc. Custom objects are created by
developers based upon application requirements.
3. Force.com provides undelete functionality on objects. Deleted objects go
to a recycle bin with an expiry date of 45 days. An administrator may delete
objects from recycle bin.
4. Objects have following fields that need to be entered by developers –
o Label
o Plural Label
o Object Name
o Description
o Record Name
o Record Type
5. The field for record name is displayed by default when the object has to be
displayed (for example in search results). The record type can be text or
auto-number. Auto-number can take values like A-{0001}, A-{0002} etc.
6. The Object name is used to access the object programmatically. __c is
added as a suffix to the custom object names. The label name is used for
display of the object.
7. The standard fields are added automatically. Examples of standard fields
are Created By, Owner etc.
8. Custom Fields are added to an object by developers. In the custom object
definition detail screen there is a section of custom fields. Click New to
create new custom fields in this area.
9. Custom Fields have properties like:
o Data Type
o Field Label
o Field Name
o Required checkbox
o Description
o Default Value
10. Examples of valid field types are
Field Type Comments
Text Text can be upto 255 characters
Text Area Text Area can be either 255 characters or 32K characters
URL
Picklist Can be single select or mult-select. The developer needs to provide valid values
Currency
Checkbox
Percent
Number
11. The field types are aligned to user interface elements like picklist and
checkbox.
12. Fields can be set as unique, required or as external id. A required field is
always displayed in the edit page. A field of type external id is a record id
from another system. The performance of reports and SOQL is better for
fields defined as external ids. Fields of type number, text and email can be
set as external id. Each object can have upto three external ids.
13. A field defined as encrypted is not visible to users. Typical usage of
encrypted field is for password. Only users with “View Encrypted Data” can
view the encrypted fields. Encrypted fields are editable.
14. Objects can have upto 500 custom fields.
15. When an object is created, a user interface is created automatically for
Create, Update, Read and Delete operations.
16. Fields of two Picklists can be made dependent on each other. As an
example consider an application with customers in US and Canada. If there
are two picklists – one for country and the other for state. Based upon
user’s selections of country, the state settings need to get updated. This is
implemented by defining controlling and dependent picklists. In the above
scenarion, country becomes the controlling picklist and state becomes
dependent picklist. The controlling and dependent picklists are defined
using “Field Dependency” button in “Custom Field and Relationship”
section.
17. Standard picklist can be controlling picklist but not dependent picklist.
Maximum number of values allowed in controlling field is 300. A custom
multi-select picklist cannot be controlling field in a picklist.
18. Merge fields are fields that display values based upon formulae
calculations.
19. Salesforce supports history tracking on change in values of fields. This can
be enabled for upto 20 fields in an object.
20. Custom objects can be represented using a Metadata XML.
21. Deleted data and metadata is stored in recycle bin.
22. Database tuning is managed by Salesforce. How Objects and fields are
stored in the database is internal to Salesforce.
Object Relationships
23. Force.com allows you to create relationship between objects. The “Custom
Fields & Relationsip” section of objects is used to define relationship
between objects.
24. There are a two types of object relationships that Salesforce supports –
A. Lookup relationship
B. Master-detail relationship
These relationship are used to implement one-to-many relationship. They
are created as fields in the child record. As an example in a recruitment
application if one applicant can have many interviewFeedbacks, we could
create a lookup (or master detail) relationship in the interviewFeedback
object pointing to the applicant object.
25. In Master Detail relationship, if the parent record is deleted, then all its
children records are deleted.
26. Child records in master-detail relationship do not have owners. They inherit
ownership from the parent record.
27. In Master detail relationship, the parent field is required. Also the parent
field once specified cannot be changed.
28. In the related list section of parent objects, only one field of the child
object is displayed by default. This is the field specified as Record Name in
the child object. To add more fields, search lookup layout needs to be
updated.
29. Rollup-summary fields are supported in master detail relationship. The
parent object can use roll-up summary field type to perform operations of
sum, maximum, minimum, count among its children records.
30. Many-to-Many relationships are implemented using two master-detail
objects. One Junction object is used as the child of the objects between
which many-to-many relationship needs to be established.
31. The table below compares Master Detail and Lookup relationship
Summary | Lookup relationship | Master Detail relationship |
Is Parent a required field | No | Yes |
Maximum number of relatioship in an object | 25 | 2 |
Security of parent determines child record’s access | No | Yes |
Deleting parent record deletes children | No | Yes |
Parent can be a child in another relationship | Yes | No |
Roll-up summary in parent supported | No | Yes |
32. Self relationship is a lookup relationship to itself. An example usage could
be organization chart where an employee’s manager is also an employee.