SQLite Forum

Main Topic and Non Main Topics (Was: Topic and subtopic)
Login
There is another organizational method which would do the constraint differently, and would ALWAYS add the main topic item into the list, and maybe remove it when you pull the list of 'non-main' topics for a given record.

This makes it easier to do the (what I presume a major purpose of the non-main topic table) search for all records that are at least somewhat (Mainly or non-mainly) connected to a given topic.

Unless there really is a need for a lot of searches for records ONLY non-mainly topically related, adding te Main Topic to the table may simplify the code. 

Yes, there will likely be a need in the UI to define a record a desire to not list the Main topic, but that is easily removed with a join and a where clause.

Now the primary restriction might be a prohibition of not listing a given topicID twice for a given record, but that is a simple unique constraint on the column pair.