Database Design - Column In One Table References Two Tables -


here example of have (take stack overflow). have 2 tables, questions , answers. have comments table. comments table reference both questions , answers.

how should set database? have 2 columns in comments, questionid , answerid. have 1 table both questions , answers? have table in between somehow tells me question or answer?

edit: found data explorer, uses 1 table both questions , answers ... don't posts table having many nulls in it. have negative effects, on performance?

stackoverflow models questions , answers being same entity: posts. have identical properties, aside indicating answer accepted/granted.

comments own table, , relate respective post using foreign key -- post_id.

without needing load monthly dumps, you can view (and query) schema via stackexchange data explorer.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -