Sign Up
Loading...

Retrieving related data across tables (example with managers and employees)

Asked by Martin on March 27, 2025

How do I retrieve employees with their associated managers for a given company (relational queries across tables)? Can I define indexes or run SQL for efficiency?


Answered by Twidget

One approach: keep company_id and manager_id fields on the Employee table. Use Get Multiple Data filtered by company_id to fetch employees, then for each employee fetch the manager by manager_id (this results in multiple calls).

For better efficiency: perform a single Get Multiple Data to fetch all employees, then use Conversion → Group Items by Field to build a map (employee_id → employee). Locally join the employees with their manager entries using that map to avoid repeated table calls.

At present Twidget does not expose raw SQL or custom index definitions; use data modeling and grouping techniques to optimize queries.

Related Questions