Quick answer
You can create up to 40 lookup relationship (LR) fields on a single Salesforce object. This limit applies to lookup relationship fields (custom) and is separate from the number of master-detail relationships.
Explanation
Salesforce enforces different limits for relationship types. The key limits to remember are:
- Lookup relationships per object: 40
- Master-detail relationships per object: 2
Lookup relationships allow one object to reference another (one-to-many), while master-detail creates a tighter parent-child relationship with cascade deletes and roll-up summary features. Because master-detail relationships have stronger implications for sharing, security, and data integrity, their count is restricted to a smaller number.
Why this matters
Hitting the lookup limit can block new integrations or data model changes. If your data model requires more relationships than allowed, consider these alternatives:
- Use a junction object (many-to-many) to model multiple relationships without adding many lookup fields to the same object.
- Consolidate references into a single relationship and store additional reference info in a related child object.
- Use external IDs or a composite key approach when integrating external systems, reducing the need for multiple lookup fields.
Practical tips
- Plan your data model early. Map out objects and relationships to avoid hitting the limit in production.
- Favor normalized designs (junction objects) over adding many lookup fields to a single object.
- Use formula fields and indexed fields carefully; excessive cross-object formulas can affect performance when many lookups exist.
- Review managed package objects: some limits can be impacted by package-specific relationships depending on namespace and packaging.
Example SOQL referencing a lookup
SELECT Id, Name, Account__r.Name, Contact__r.Email FROM Custom_Object__c WHERE Account__r.Industry = 'Technology'
This demonstrates how to traverse lookup relationships in SOQL using the relationship name (Account__r, Contact__r) to access parent fields.
References
Always check the latest Salesforce Limits documentation as limits can change between releases. The above numbers are commonly quoted limits in Salesforce editions for custom objects.








Leave a Reply