in reply to Re^2: Pseudo-Polymorphism
in thread Pseudo-Polymorphism

In SQL, I would generally handle that something like this:

CREATE TABLE entity_ones ( id INTEGER, -- whatever goes in this table ); CREATE TABLE entity_twos ( id INTEGER, -- whatever goes in this table ); CREATE TABLE comments ( id INTEGER, author VARCHAR(128), content TEXT, -- etc ); CREATE TABLE entity_one_comments ( entity_one_id INTEGER NOT NULL REFERENCES entity_ones(id), comment_id INTEGER NOT NULL REFERENCES comments(id), PRIMARY KEY ( entity_one_id, comment_id ) ); CREATE TABLE entity_two_comments ( entity_two_id INTEGER NOT NULL REFERENCES entity_twos(id), comment_id INTEGER NOT NULL REFERENCES comments(id), PRIMARY KEY ( entity_two_id, comment_id ) );

We're not surrounded, we're in a target-rich environment!