Solution 2: Create a Common Super-Table

Let’s understand how creating a common super-table helps us avoid the Polymorphism Association.

In object-oriented polymorphism, two subtypes can be referenced similarly because they implicitly share a common supertype. In SQL, the Polymorphic Associations antipattern leaves out that crucial entity: the common supertype.

Creating a common super-table

We can fix the mentioned issue by creating a base table that all of our parent tables are extended from (see Class Table Inheritance). We can add the foreign key in the child Comments table to reference the base table. We don’t need an issue_type column.

Get hands-on with 1200+ tech skills courses.