Search code examples
salesforcestorageapex-codesoql

Salesforce Best Practice To Minimize Data Storage Size


I need to add an array of strings (approximately 1-5 strings 10-30 characters long) to one of my custom objects.

From what I've read, Salesforce multiplies the total number of objects in your Org by 2Kb (regardless of actual size) to calculate your total data storage.

This makes me think I should just create additional custom fields on the parent object instead of creating a new custom object and pairing it with a master-detail relationship.

Example: A club that only sells family memberships. The parents pay a fixed membership fee and all of their kids can visit the club. The club doesn't care how many kids you have. It's extremely rare that a family has more than 6 kids. The club wants to keep track of the kids' names but absolutely nothing else about them.

Should I do option 1:

Family__c paired via master-detail to many Child__c objects

Which would produce 6 records totaling 12Kb for a family of 5 kids.

or option 2:

Family__c has 6 custom fields called 
    Child01__c, Child02__c, Child03__c, Child04__c, Child05__c, and Child06__c

Which would produce 1 record totaling 2Kb for a family of 5 kids.

Is it true that Salesforce calculates data storage based solely on number of records?

When designing custom objects, should I focus on a design that aims to minimize the number of total records instead of a traditional relational database design? (because of the 1Gb limit on data)


Solution

  • Option 2 is the better choice for the very reason you specify. You are correct that Salesforce.com will consume 2kb per row of your custom object, regardless of how many fields it actually contains. Also, in general, if you're going to have a 1-to-1 object like this one, you're better off just putting it in fields on the main object anyway; it saves you a lookup and makes things like reporting and list views easier.