I have a column of data in a SQLite database indicating which sensor data is included in that row. The problem is that there can be multiple sensors updated at a time, delimited by | and in no guaranteed order.
What I have in my table Data:
*-------*----------------------*
* RowID * Sensor               *
*-------*----------------------*
*    1  * 'EEG|Eyetracker|GSR' *
*    2  * 'Eyetracker|GSR'     *
*    3  * 'GSR|EEG'            *
*    4  * 'EEG|EyeTracker'     *
*-------*----------------------*
I want to extract all unique sensor names, like so:
*------------*
* Sensor     *
*------------*
* EEG        *
* Eyetracker *
* GSR        *
*------------*
And then replace the single Sensor column with a table with a foreign key to that row:
* -----------*------------*
* Sensor     * Data.RowID *
* -----------*------------*
* EEG        * 1          *
* Eyetracker * 1          *
* GSR        * 1          *
* EyeTracker * 2          *
* GSR        * 2          *
* GSR        * 3          *
* EEG        * 3          *
* EEG        * 4          *
* EyeTracker * 4          *
* -----------*------------*
I've looked around, but this answer and this answer are specific to SQL Server, not SQLite. This answeris pure SQLite, but is not actually what I am looking for.
I think this may be a use-case for CTE's, but I don't know how I would go about using a CTE for this.
