Matilda
Matilda

Reputation: 1718

website and mysql design question

I have a ROR website where people can ask relationship questions and other people can vote yes or no and reply to/advice them on their question.

I want to have a check box next to the reply text-box that the person who asked the original question can come and check that, close the case and tell them the result of the relationship.

so for example if she tells a story and ask "you think he likes me?"... then she can come and reply "he did like me" and close the case.

I have a model for comments and a model for replies. I am thinking of adding a column 'resolution' to replies table that implies it's the closing reply from the user and the result was 0 or 1, if the answer was yes or no, or NULL for replies that are not the closing case.

I also want comment object to know if it had a closing result and what the result was.

So in the website overtime some one loads the site it needs to look for each comment see if any of the replies are closed, then the comment is closed.

I think this could be very intensive, should I add the same column also to the comment table so it can only check that?

Upvotes: 1

Views: 55

Answers (2)

mu is too short
mu is too short

Reputation: 434945

One alternative would be to have a resolution_id column in your question table and have that be a reply. Then set up a has_one relationship and you're good.

You'd be able to get the resolution straight out of the question and easily see if a question has been resolved, you'd also have at most one resolution per question.

Upvotes: 1

idstam
idstam

Reputation: 2878

I would add resolution only to the comment table.

Upvotes: 0

Related Questions