All Questions
Data Modeling medium

In Rails/Django, a 'Polymorphic Association' allows a `Comment` to belong to either a `Post` or a `Video`. Why is this often considered an anti-pattern in SQL?

  1. A It consumes excessive amounts of physical memory during complex traversal operations that require multiple recursive self-joins.
  2. B It breaks Referential Integrity at the database level, as you cannot define a standard Foreign Key constraint that validates against multiple tables.
  3. C It is not natively supported by modern high-level ORMs like ActiveRecord or Django, forcing developers to write raw, unoptimized SQL for all associations.
  4. D It requires the use of specialized semi-structured JSONB columns that are significantly slower to index and query than standard relational attributes.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions