Joining Tables
RevenueBase data is organized into separate tables that link together through shared keys. This page explains how the tables relate and how to join them correctly.Entity relationship overview
Here’s how the main tables connect:Join keys reference
| From table | To table | Join key | Join type | Notes |
|---|---|---|---|---|
contacts | companies | contacts.company_id = companies.company_id | LEFT JOIN | Not all contacts have a company |
contacts | emails | contacts.contact_id = emails.contact_id | LEFT JOIN | A contact may have multiple emails |
companies | emails | companies.company_id = emails.company_id | LEFT JOIN | All emails associated with a company |
| TODO: Add more joins |
Common join patterns
Contacts with company info
The most common join — enriching contacts with their company’s firmographic data:Use
LEFT JOIN (not INNER JOIN) if you want to include contacts that don’t have a company record. Use INNER JOIN if you only want contacts with a known company.Contacts with their primary email verification details
Full join: contacts + companies + emails
Gotchas and tips
Duplicate rows from one-to-many joins
Duplicate rows from one-to-many joins
If a contact has multiple email records, joining
contacts to emails will produce one row per email. To avoid duplicates, filter on e.is_primary = TRUE or use a subquery to pick one email per contact.NULL company_id
NULL company_id
Not every contact has a linked company. If you use
INNER JOIN on companies, you’ll silently drop those contacts. Use LEFT JOIN unless you specifically want to exclude unmatched contacts.Performance on large joins
Performance on large joins
When joining across large tables, always include filter conditions (
WHERE clauses) to reduce the working set before the join. Filtering on email_verified, last_verified_at, or industry early will significantly speed up queries.TODO: Add more gotchas
TODO: Add more gotchas
Fill in based on common support questions and customer mistakes.
Joining with your own data
You can also join RevenueBase tables with your own internal data in Snowflake. The most common approach is matching ondomain:
