🔗 Interactive SOQL Relationships
Master Parent-to-Child and Child-to-Parent Queries with Visual Learning
Progress: 0% Complete
SOQL (Salesforce Object Query Language) is used to search your Salesforce data. Understanding relationships is key to powerful queries!
🎮 Interactive Object Relationship Map
Parent Object
Child Object
Child Object
Parent-to-Child queries use subqueries to fetch related child records. Perfect for getting all contacts for an account!
🎮 Interactive Query Builder
📋 Example: Account with Contacts
💰 Example: Opportunity with Line Items
✏️ Practice: Build Your Own Parent-to-Child Query
Child-to-Parent queries use dot notation to access parent object fields. Navigate up the relationship hierarchy!
🎮 Interactive Relationship Navigator
Click to navigate to Account
Click to navigate to Account
Click to navigate to Contact
👤 Example: Contact with Account Info
📋 Example: Case with Contact & Account
🧩 Drag & Drop: Build Dot Notation
Combine both techniques for powerful multi-level queries that traverse multiple relationships!
Lookup relationships are more flexible – child records can exist without parents.
🔍 Example: Lead with Campaign Info
Master-Detail relationships are tighter – detail records cannot exist without master records.
🏗️ Example: Opportunity Line Item with Product
The most powerful queries combine both parent-to-child AND child-to-parent techniques!
🌟 Ultimate Example: Account Hierarchy
🎯 Challenge: Build a Complete Business Report Query
Create a query that shows accounts with their opportunities and the primary contact for each opportunity.
Test your SOQL relationships knowledge with this comprehensive quiz! Track your progress and get personalized feedback.
🎯 SOQL Mastery Quiz
Ready-to-use SOQL queries for common business scenarios. Click any query to copy it!
👥 All Contacts for Each Account
📞 Contact Details with Account Info
💰 Opportunities with Products
📋 Support Cases with Full Context
📊 Sales Team Performance Report
🎯 Marketing Campaign Effectiveness
🏢 Account Hierarchy Management
🎓 Student Enrollment System
🔄 Complex Multi-Object Query
📈 Territory Management Query
🏭 Manufacturing Supply Chain
🏥 Healthcare Patient Management
⚡ Optimized Large Data Query
🎯 Selective Query Pattern
📊 Aggregate Query Examples
🔍 Dynamic SOQL Patterns
🎯 Quick Query Generator
🌳 Parent-to-Child (Subqueries)
Syntax: (SELECT fields FROM ChildObject)
Use Case: Get all related child records
Example:
SELECT Name, (SELECT Name FROM Contacts) FROM Account
🔗 Child-to-Parent (Dot Notation)
Syntax: ParentObject.Field
Use Case: Access parent object fields
Example:
SELECT Name, Account.Name FROM Contact
⚠️ Important SOQL Limitations
- User Object: Cannot use subqueries – query FROM other objects TO User instead
- Subquery Depth: Only one level deep allowed
- Dot Notation: Maximum 5 relationship levels
- Relationship Names: Use API names, not object names
- Security: Field-level security and sharing rules apply
- Governor Limits: 50,000 records max per query
SELECT (SELECT Name FROM Accounts) FROM User✅ Correct:
SELECT Owner.Name FROM Account
🚀 Pro Tips
- Use WHERE clauses in subqueries for filtering
- Add ORDER BY in subqueries for sorting
- Combine both techniques for powerful queries
- Test queries in Developer Console first
