My table has the following table:
- teams
- leagues
- players
- coaches
- keywords
Now, in the keywords table, there are few columns: id, topic_id, topic_type.
For teams, leagues, players and coaches they have multiple keywords(one-to-many relationship with keywords). For instance: if there is team ABC with id 4 in team table; in keywords table, there will be id, 4, team. If there is player CDE with id 3 in the player table; in keywords table, there will be id,3, player and so on.
So, here what I'm trying to do is adding a constraint in keywords that will allow me to delete the keyword when the topic is deleted from any topic_type. How do I do it? We can easily do it via Schema ondelete Cascade from reading some of the answers, but in my case, there should be a constraint on 1 item but from multiple sources.
How can I set a constraint on keywords table from all teams, leagues, players and coaches?
Thank you