Communicating Query
Assumptions
Learn how to identify, document, and communicate the hidden assumptions and limitations behind every SQL query you write.
What Are Query Assumptions?
Every SQL query rests on beliefs about the data that are not checked by the query itself. These beliefs are called query assumptions: things you take for granted about column values, row uniqueness, relationships between tables, and the meaning of NULL.
Why Communication Matters
SQL queries are often shared with teammates, managers, and stakeholders who rely on the results to make decisions. If your assumptions are wrong or unstated, the conclusions drawn from the data will be misleading.
The Hidden Iceberg of a Query
The Core Rule
This means that communicating assumptions is not optional: it is part of writing correct, professional SQL. A query without documented assumptions is like a math proof without stating its premises.
Five Categories of Assumptions
Assumptions vs. Limitations
| Assumption | Limitation | |
|---|---|---|
| Definition | A belief about the data you treat as true | A known constraint on what your query can show |
| Who controls it | The data source (you hope it holds) | You, the query writer |
| Example | email column has no duplicates | Query only covers the last 90 days |
| If wrong | Results are silently incorrect | Results are correct but incomplete |
How to Identify Assumptions
How to Communicate Them
Example 1: Active Users
Example 2: Revenue by Region
Example 3: Churn Rate
The Communication Flow
Common Mistakes
Summary Reference
| Category | Ask Yourself | How to Communicate |
|---|---|---|
| Completeness | Is all relevant data present? | "Excludes rows where X is NULL" |
| Quality | Are values consistent and accurate? | "Assumes status is always lowercase" |
| Relationships | Are JOINs \(1:1\) or \(1:\text{many}\)? | "JOIN may duplicate rows if \(1:\text{many}\)" |
| Temporal | Does the time range cover the need? | "Data covers Jan 1 to today only" |
| Business Logic | Do terms mean the same to everyone? | "'Churned' means no order in 90 days" |
Question 1 of 5
A colleague writes a query using INNER JOIN between orders and customers. They report total revenue. What is the most important assumption to communicate?
Question 2 of 5
What is the difference between a query assumption and a query limitation?
Question 3 of 5
A data analyst shares the following query:
SELECT department, AVG(salary) FROM employees WHERE status = 'full-time' GROUP BY department;
They present the results as "Average Salary by Department" with no additional notes.
Which assumption is most critical to communicate about this query?
Question 4 of 5
Your query uses COUNT(email) to count customers. A teammate points out that some customers have NULL email addresses. What is the best response?
Question 5 of 5
Which of the following is the best practice for documenting query assumptions in a shared codebase?