Databases · Middle · Question 57 of 75
What is polymorphic association, and what's its problem?
- 1A view over several tables
- 2A table with columns of different types
- ✓Correct answer: A table like
comments(commentable_type, commentable_id)pointing to different tables; the database can't enforce a foreign key on it
Explanation
Alternatives: separate nullable foreign keys with a CHECK that exactly one is set, or a separate junction table per parent type.