All Collections
Getting Started
Crafting Perfect Queries in InsightBase
Crafting Perfect Queries in InsightBase

Learn the best practices for querying your database to get the most out of it.

Dan avatar
Written by Dan
Updated over a week ago

The key to getting the response you want is asking the right way, and in this article, we'll show you how to do it.

For the sake of this guide, we'll consider a database for an events SaaS product that sells tickets to events.

Ask questions, instead of affirmations

Let's say you want to get the total number of customers.

Wrong: "Total Customers"

Right: "How many customers do we have?"

While the wrong version could still work, the second way is much better and much easier to understand for our system.

This is even more helpful when the question is more complex, like for instance, the total number of customers acquired in the last 30 days.

Wrong: "Customers last month"

Right: "How many customers did we get in the last 30 days?"

Be specific

Let's say that you want to know what's the average attendance rate for all the events.

Wrong: "What's the attendance rate?"

Right: "What's the average attendance rate for all the events?"

"Attendance rate" can be a very wide term, and it could apply to one or more "entities" from your database. By specifying that it's for the events, the system will be able to offer you a much better response.

Add explanations

Let's say that you define a "successful" event as an event with an "attendance rate" > 60%, and you want to calculate the percentage of successful events.

Wrong: "What's the percentage of the successful events?"

Right: "What's the percentage of successful events (A successful event is an event where the attendance rate is more than 0.5)"

Our system doesn't know what you consider a successful event, and this is why you have to specify what you consider a successful event.

Did this answer your question?