My database designs have previously been rather linear, so I’m getting stumped on what is probably a very easy to solve problem.
I have a table of ‘POSTS’, which contain posts which may be a child of either a ‘CATEGORY’ or a ‘TOPIC’. What would be the best way to define the foreign key(s) for the ‘POSTS’ table?
I suppose I could have a column named POST_CATEGORY_ID and a field named ‘POST_TOPIC_ID, which could be nullable, but this just doesn’t sound right. Surely there is a simple solution that I’m missing!
You could do many-to-many relationships between POST and CATEGORY and POST and TOPIC:
This way, a post can be associated with any number of categories and topics.