KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have following comments table in my app: comments -------- id INT foreign_id INT model TEXT comment_text TEXT ... the idea of this table is to store comments for various parts of my app - it can store comments for blog post i.e.: 1|34|blogpost|lorem ipsum... user picture: 2|12|picture|lorem ipsum... and so on. now, is there a way to force FOREIGN KEY constraint on such data? i.e. something like this in comments table: FOREIGN KEY (`foreign_id`) REFERENCES blogposts (`id`) -- but only when model='blogpost'
Tags (comma-separated)
Save Edits
Cancel