I want to manage lists with a various number of entries. Currently I am using the following table structure.
CREATE TABLE lists (
list_id INTEGER,
sort_id INTEGER,
content_id INTEGER,
PRIMARY KEY (list_id,sort_id)
)
So I can call an individual list using:
SELECT content_id WHERE list_id=<<X>> ORDER BY sort_id
In principle adding a new list is not a problem, but how can I check for duplicates of a complete list before inserting a new set of a list? I give an example:
There is the following list already inserted:
list_id | sort_id | content_id
--------+---------+-----------
3 | 1 | 7
3 | 2 | 4
3 | 3 | 9
A new list with the content 7,4,9 would be an duplicate and must not be inserted. But the content 4,7,9 or 7,4 or 7,4,9,5 must be insertet due to my definition of a different list-content.
I thought of adding a new table, that contains the concatenated content of a list, something like:
CREATE TABLE lists_concat (list_id PRIMARY KEY, content_concat UNIQUE)
So for my example there would be the entry
list_id | content_concat
--------+---------------
3 | 7,4,9
This would work, but it seems to be very complicated. Is there an easier way? I am also open to use another table structure for my lists. Tell me please about your ideas.
Thanks a lot