Querying entities in Analytics

You can use the entity tables to map various properties of Formant entities. For example, the query_numeric table can show you all numeric data points for a particular device_id, but you may want to present that data to the user with a more friendly label, like the device name.

Entity tables in Formant Analytics.

Entity tables in Formant Analytics.

This guide will teach you how to use the entity mapping tables in Formant Analytics.

Mapping table structure

mapping_account

ParameterUsage
idID of this account.
organization_idID of the organization to which this account belongs.
tagsTags associated with this account.
nameName of this account.
time

mapping_device

ParameterUsage
idID of this device.
organization_idID of the organization to which this device belongs.
tagsTags associated with this device.
nameName of this device.
time

mapping_fleet

ParameterUsage
idID of this fleet.
organization_idID of the organization to which this fleet belongs.
tagsTags associated with this fleet.
nameName of this fleet.
time

mapping_organization

ParameterUsage
organization_idID of this organization.
tagsTags associated with this organization.
nameName of this organization.
time

mapping_team

ParameterUsage
idID of this team.
organization_idID of the organization to which this team belongs.
tagsTags associated with this team.
nameName of this team.
time

mapping_user

ParameterUsage
idID of this user.
organization_idID of the organization to which this user belongs.
tagsTags associated with this user.
first_nameFirst name of this user.
last_nameLast name of this user.
time

Example: list devices by event count

Suppose you want to list all devices in your organization in descending order of event count. You want to include devices which have no events, and you want to present this to the user with a user-friendly device name, instead of the alphanumeric device ID.

In your SQL query, you'll select the mapping_device.name column, which contains the names of all devices in your organization, and LEFT JOIN the query_event table on the mapping_device table. This will return event counts for all matching device_id parameters, while still displaying mapping_device.name values without a corresponding event count:

SELECT
	mapping_device.name,
  COUNT(query_event.device_id) AS event_count
FROM
	mapping_device
LEFT JOIN
	query_event
ON
	mapping_device.id = query_event.device_id
GROUP BY
	mapping_device.name
ORDER BY
	event_count DESC;
Entering the SQL query in the SQL editor.

Entering the SQL query in the SQL editor.

Displaying the result with user-friendly device names.

Displaying the result with user-friendly device names.

See also

👋

If you notice an issue with this page or need help, please reach out to us! Use the 'Did this page help you?' buttons below, or get in contact with our Customer Success team via the Intercom messenger in the bottom-right corner of this page, or at [email protected].