First time here? Check out the FAQ!
2

what is the relationship between 'thread' and 'question_post'?

Thread is a class that holds information that is specific to question_post (not other types of posts)?

Can you give another view/explanation about the relationship between the two?

I'd like to add ManyToMany relationships between question_post to question_post.
Should I make it in Thread or Post?

pcompassion's avatar
21
pcompassion
asked 2013-05-28 21:24:10 -0500, updated 2013-05-28 21:25:16 -0500
edit flag offensive 0 remove flag close merge delete

Comments

Just to clarify - at the moment we do not have a relation to question_post from Thread, but we actually should.

Evgeny's avatar Evgeny (2013-05-29 00:08:37 -0500) edit
add a comment see more comments

1 Answer

2

Thread model is there to separate data relevant to the thread as a whole and that of posts. The separation is not always clean - for example votes are duplicated on thread and post.

Thread contains title and tags and post does not, there are some other fields that are only present in the Thread.

All posts used for Q&A have a relation to Thread via a foreign key. Posts of type != either one of 'question', 'answer' or 'comment' may have nulled relation to thread.

Post actually already contains a relation to post - called "parent" - this one is used to associate comments with their parent posts. If you want to add another - it will be necessary to give a unique "related_name".

Another piece is PostRevision, which confusingly does store revision info on tags and titles.

This modeling would be simpler with just Post and PostRevision, but in that case Post would have to carry lot's of fields that would not be used most of the time.

Another consideration for the data modeling is performance: as we have it now - we can load all posts for one thread with one query - by the thread_id and then sort them out into question, answers and comments. Originally we had models Question, Answer and Comment and you can imagine how many more queries were necessary to load data for the question detail page.

Evgeny's avatar
13.2k
Evgeny
answered 2013-05-29 00:04:02 -0500, updated 2013-05-29 00:06:45 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments