I am working with an SQLite3 database. And I want to create an FTS5 content-less (content="") or content="external table" table to save space and prevent duplication of data (which occurs if I don't use a content-less or external-content table).
My scenario =>
tableA (textColumn, idColumn)
tableB (textColumn, idColumn)
tableFTS5 (textColumn, textIdColumn, tableNameColumn)
What I do =>
I insert data into tableA and tableB. Then I read all rows from tableA and insert into tableFTS5 table as
tableFTS5.textColumn = tableA.textColumn,
tableFTS5.textIdColumn = tableA.idColumn,
tableFTS5.tableNameColumn = "tableA"
I repeat this for tableB also with tableFTS5.tableNameColumn = "tableB".
What I need is =>
I want to query tableFTS5 for some text and I want to retrieve just tableFTS5.textIdColumn and tableFTS5.tableNameColumn. With these two column values in hand, I can retrieve the original data from tableA or tableB.
Is it possible to retrieve these columns from tableFTS5 if tableFTS5 is a content-less or content="external" table, maybe with some triggers or any other method ?
My source of info about this Link to SQLite3 FTS5 docs
Ok. So one approach I can take is =>
I have two main tables with text data (I don't want to duplicate this data).
And I create one mapping table to map the main table names and their text ids to rowids of FTS table.
And I have one FTS content-less table which only returns rowids.
But with this approach I have to manage insert, delete operations for FTS table and mapping table too. This got too complicated to manage so I decided to go for creating individual FTS table for every main table and setting content="that main table name"
But I would really prefer if there is an option for content-less FTS table to store and return some user specified columns for the purpose of storing some ids and not the text content columns (because that would create duplication of text).
What I was trying to achieve is called one to one polymorphic relationship so I don't have to create too many tables.
If I had this option for content-less FTS table then for 6 text data tables I would create only one FTS table, so total tables = 7. But now without this option I would create 12 tables, 6 main and 6 FTS
I request developers to add this option to sqlite. Many thanks