In a StackOverflow clone, what relationship should a Comments table have to Questions and Answers?
I’d go with the Posts approach. This is the best way to ensure referential integrity. If you need additional columns for Answers and Questions respectively, put them in additional tables with a one-to-one relationship with Posts. For example, in MySQL syntax: CREATE TABLE Posts ( post_id SERIAL PRIMARY KEY, post_type CHAR(1), — must be ‘Q’ … Read more