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

It's not represented as a(n) SQL relationship, but there are always at least two records in sqlth_drv:

Each tag provider you add to a given gateway will create a new row in sqlth_drv with the gateway name and provider name. When it comes time to retrieve history, the historian "knows" to look for the entry with a null provider.