How does drvid in sqlth_partitions relate to scid and to entries in sqlth_te?

I’m trying to figure out if my SQL queries should care about the drvid that is in the sqlth_partitions table. I need to go from an entry in sqlth_te to a query against a historical data table (e.g., sqlt_data_1_2019_04).

Here’s a snapshot of the tables on a clean installation of Ignition:
Capture

Capture2

Capture3

All good so far… we can map from a tag entry to a drvid.

Now we look in sqlth_partitions:

Capture4

No entry for drvid == 2.

How do I make that final leap?

If you will only ever have one Ignition gateway talking to this database, then you can probably ignore sqlth_drv - you will still need it if you add any more realtime tag providers to this gateway as well.

Thanks PGriffith-- however it is the case that there will be multiple gateways/providers. (This question is in the context of an Ignition Module that my company writes and maintains.)

One pattern I noticed is that the sqlth_partitions table only ever seems to reference a drvid entry in sqlth_drv where “provider” is null. Is that always the case? If so I could do this (somewhat crazy) SQL command to narrow in on the drvid that is used by sqlth_partitions:

SELECT sqlth_te.id AS tagid, gateway.id as drvid FROM sqlth_te
  INNER JOIN sqlth_scinfo ON sqlth_scinfo.id = sqlth_te.scid
  INNER JOIN sqlth_drv ON sqlth_drv.id = sqlth_scinfo.drvid
  INNER JOIN sqlth_drv AS gateway ON sqlth_drv.name = gateway.name
  WHERE gateway.provider IS NULL;