0

If you have custom data that is one-to-one with a standard record, what are some example circumstances where you should or should not:

  • create custom fields in the standard object?
  • create a custom object in a one-to-one relationship?

If the answer is "always use A, never B" or "neither, always use [something else]", please explain why.

1

The answer is usually "create a field in the same object." This is sort of implied by the "rules" of database normalization (the First Normal Form, Second Normal Form, etc). You can do a search to learn more, but basically speaking, all data that isn't duplicated belongs in the same table, and data that would be duplicated should be in separate tables so they are no longer duplicated.

However, there are exceptions to the rules. For example, you may have a double-book accounting system, where each debit has an associated credit. In this case, each record will have a 1:1 relationship, but you need the data to roll up to each account separately.

Or, you might find that you need more than the maximum number of allowed relationships or fields, so you need to split the table (we actually ran in to this problem in our production org!). Or, it might be a matter of security, where you need some of the data hidden from some users, and for some reason, field level security won't work. There are at least several good reasons why a custom field simply won't work.

Using a separate custom object has several penalties. First, more storage will be used (2kb per record), so you'll double up on the storage you're using with the latter design. Second, you're limited to the number of relationships you can create on a single object. Third, this design means more data entry screens or custom code to meld the data into one view/edit mode.

So, in summary, the answer is "usually custom fields, unless you have a specific reason otherwise."

1
  • Just to add to the brilliant answer by @sfdcfox, since you can't add relationships to custom objects on User object, we had to go with a custom object for each user - that's one of those 'specific reasons' in SF world. – zaitsman Jul 2 '20 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.