In order to accommodate for the storage usage, Wikidata will provide terms-related tables from a separate server/cluster than the rest of Mediawiki/Wikibase tables.
In order to allow make use of those, Wikibase persistence logic needs to use the right database/cluster for the relevant queries.
Currently in Wikibase the database details and connections are modeled through DomainDb classes.
It is expected that Wikibases other than Wikidata wouldn't need to separate database tables, so two "pointers" could still lead to one database. The "term-database" connection setting should be optional, and unless specified differently, assume to use the "general" Mediawiki/Wikibase database.
Original description for history/context below:
Currently term store is reaching 340GB in wikidata and slowly reaching the wb_terms era. To allow splitting s8 into a core cluster and a dedicated cluster for term store (tentatively called x3), we need to make term store take a different domain db than the core db of wikidata (and should be configurable and initially pointing to wikidata db). This would free up space for wikidata and reduces write pressure and allows for more horizontal scaling.
As an example, see how RepoDomainDb is injected in TermStoreWriterFactory or DatabaseTermStoreWriterBase.