How to Build Account Hierarchies in DenchClaw
Build account hierarchies in DenchClaw to model parent-child company relationships, subsidiaries, and holding structures—with DuckDB relations and recursive views.
Enterprise sales requires understanding who you're really selling to. A deal with a subsidiary might be influenced by decisions made at the parent company. A global enterprise might have independent divisions each capable of buying separately. Without account hierarchies, your CRM treats each company as an island—and you end up with incomplete context on your biggest opportunities.
DenchClaw's relational data model in DuckDB handles account hierarchies natively. Here's how to set them up.
What Account Hierarchy Means in Practice#
Account hierarchies model parent-child relationships between companies:
- Parent account: The ultimate owner (e.g., Alphabet Inc.)
- Child accounts: Subsidiaries or divisions (e.g., Google LLC, YouTube LLC, DeepMind)
- Peer accounts: Divisions at the same level (e.g., Google Cloud, Google Ads)
For sales purposes, you might sell to Google Cloud and later discover that Google Ads is also a prospect. Without hierarchy data, you'd treat these as unrelated accounts. With hierarchy, you know they share a parent—which means shared budget cycles, potentially shared procurement, and existing relationships you can leverage.
Step 1: Add Parent Account Field to Companies#
The simplest way to model hierarchy is a self-referential relation field on your companies object:
"Add a field called 'Parent Account' to my companies object.
Type: relation to companies (many-to-one, self-referential).
This links a subsidiary company to its parent company."
This creates a foreign key relationship within the same table. Every company entry can optionally point to another company entry as its parent.
Step 2: Add Hierarchy Level and Type Fields#
Help categorize the structure:
"Add these fields to my companies object:
Hierarchy Level (enum: Global HQ, Regional HQ, Business Unit, Subsidiary, Department),
Account Type (enum: Enterprise Parent, Subsidiary, Independent, Division),
Total Employees Group (number, for the whole corporate group),
Website (url), Industry (enum)."
Hierarchy Level tells you where in the org structure a company sits. A "Global HQ" should have different pipeline strategy than a "Subsidiary."
Step 3: Enter the Hierarchy Data#
Build the parent-child relationships for your target accounts:
"I need to set up account hierarchy for Alphabet.
Create an entry for Alphabet Inc as the parent company (Global HQ).
Then link these existing companies to it as children:
Google LLC, YouTube LLC, DeepMind, Waymo, Verily."
For companies you're prospecting, research their corporate structure first:
"Look up the corporate structure for Microsoft. Find all major subsidiaries
and business units. Create company entries for each and link them to
Microsoft Corp as the parent."
The browser agent can visit corporate pages, Wikipedia, or company websites to pull this information.
Step 4: Visualize the Hierarchy#
Once you have parent-child relationships set up, query them:
"Show me the account hierarchy for Alphabet.
List all child companies with their industry, deal status, and primary contact."
DenchClaw runs a SQL query joining the companies table to itself via the parent_account relation:
SELECT child.company_name, child.industry, child.deal_status,
parent.company_name as parent_company
FROM v_companies child
LEFT JOIN v_companies parent ON child.parent_account = parent.id
WHERE parent.company_name = 'Alphabet Inc'
OR child.company_name = 'Alphabet Inc'
ORDER BY parent_company, child.company_nameStep 5: Track Deals Across the Hierarchy#
Enterprise deals often start at a business unit but need approval at the parent level. Track this:
"For any deal where the company has a Parent Account,
show me the parent company, the subsidiary we're actually dealing with,
the deal value, and whether we have a relationship with anyone at the parent."
This view helps you spot deals that might need executive sponsor relationships at the parent level to close.
Step 6: Aggregate Revenue by Parent Account#
One of the highest-value uses of account hierarchy is seeing total customer value by corporate group:
"Show me total revenue (closed deals) and open pipeline value by parent account,
including all subsidiaries."
This query sums across the hierarchy:
SELECT COALESCE(parent.company_name, c.company_name) as group_name,
SUM(d.deal_value) as total_pipeline,
SUM(CASE WHEN d.stage = 'Closed Won' THEN d.deal_value ELSE 0 END) as closed_revenue
FROM v_deals d
JOIN v_companies c ON d.company = c.id
LEFT JOIN v_companies parent ON c.parent_account = parent.id
GROUP BY group_name
ORDER BY total_pipeline DESCA company group you thought was a small deal might turn out to be your largest account when you count all subsidiaries.
Step 7: Build Expansion Intelligence#
Hierarchy data powers expansion sales:
"Show me all parent companies where we have at least one paying subsidiary.
For each, show which subsidiaries are customers and which subsidiaries
are still prospects."
This is your expansion map. If you've closed Google Cloud, you have a warm path to Google Ads and Google Workspace. The parent-child relationship gives you the context; the query surfaces the opportunity.
Step 8: Handle Acquisitions and Mergers#
Companies change structure. When an acquisition happens:
"LinkedIn was acquired by Microsoft.
Update LinkedIn's Parent Account to Microsoft Corp.
Add a note to both accounts: 'LinkedIn acquired by Microsoft in 2016.'"
Keep historical accuracy by adding a Structure Changed date field so you can query what the hierarchy looked like at a specific point in time.
Frequently Asked Questions#
How deep can the hierarchy go?#
DuckDB supports recursive CTEs, so you can query arbitrarily deep hierarchies. In practice, most corporate structures are 3-4 levels deep (Global HQ → Regional → Business Unit → Department).
What if a company has multiple parents (joint ventures)?#
Add a second Parent Account 2 field for cases where a subsidiary is jointly owned. Most CRMs don't handle this well; DenchClaw's flexible field schema can accommodate it.
Should I create a company entry for every subsidiary, even ones I'll never sell to?#
For major corporate groups you target heavily, yes—it gives you full visibility. For incidental subsidiaries, no. Focus on entries that have sales relevance.
How do I prevent duplicate companies for subsidiaries with similar names?#
When creating hierarchy entries, search first: "Is there already a company called 'Google' or 'Google LLC' in my CRM?" If a near-duplicate exists, update the existing entry rather than creating a new one.
Can I track contacts across the hierarchy?#
Yes. Your contacts are linked to specific company entries (e.g., a contact at Google Cloud). By following the parent chain, you can see all contacts across the entire Alphabet corporate group.
Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →
