Designing a user-friendly query interface
SQL is too complex. Let's build something better.
But they don't want to write SQL queries.
Pre-built queries for common use cases. No coding required.
Example:
GET /api/templates/red-flag-scanner
{
"cik": [789019, 1018724],
"date_range": "2024-Q3"
}
Suggested Templates:
Flexible JSON query language without SQL. Covers 80% of use cases.
Example:
POST /api/query
{
"filters": {
"and": [
{"event_type": {"like": "upgraded%"}},
{"sentiment": "positive"},
{"idf_score": {"gte": 7.0}},
{"filing_date": {"between": ["2024-01-01", "2024-12-31"]}}
]
},
"sort": [{"filing_date": "desc"}],
"limit": 100
}
Supported Operators:
Complex pattern detection, event sequences, and aggregations for data scientists.
Pattern Detection Example:
POST /api/query/advanced
{
"type": "pattern_detection",
"pattern": {
"events": [
{"event_type": "dismissed_auditor", "name": "red_flag"},
{"event_type": "material_weakness", "name": "control_issue"}
],
"within_days": 180,
"sequence": "any"
},
"groupBy": "cik"
}
Capabilities:
LLM-powered queries. Ask questions in plain English.
Example:
POST /api/query/natural
{
"query": "Show me companies that got credit upgrades in 2024 and then expanded into new markets",
"max_results": 50
}
How it works:
Pros:
Cons:
Build queries once, save them, reuse them.
• Save queries with names
• Share queries with team
• Schedule queries (alerts)
• Export results to CSV/JSON
Drag-and-drop interface that generates queries.
• Select fields to filter with dropdowns
• Add conditions visually
• Preview results in real-time
• Export as JSON/SQL
| Approach | User-Friendly | Flexibility | Dev Effort | Best Use Case |
|---|---|---|---|---|
| Query Templates | ⭐⭐⭐⭐⭐ | ⭐⭐ | Low | Common queries, non-technical users |
| Query Builder DSL | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | Medium | Power users, programmatic access |
| Advanced Queries | ⭐⭐ | ⭐⭐⭐⭐⭐ | High | Complex analytics, data scientists |
| Natural Language | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | Medium | Non-technical users, exploration |
| GraphQL | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | Medium | Frontend developers |
| Visual Builder | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | High | All users, reduces support burden |
Start simple, add complexity as needed based on real user feedback.
Why this order?
✓ Query Builder DSL covers 80% of use cases
✓ Templates make common queries instant
✓ Can add NL queries later if needed
✓ Avoids over-engineering before feedback