2
I’m creating a comment structure similar to Mercadolivre, how do I make the modeling contemplate and ensure that:
NOTE: I’m calling comments question and answer since this is basically how the Free Market model works.
In red questions and in green the answers.
- There is only one level of answer for a given question.
- A question have several answers.
- An answer to a single question.
- No questions for an answer.
- Questions and answers for a single product.
- Be possible to be redirected to comment as here on Sopt (en.stackoverflow.com/questions/78765/problems-with-post-Angularjs/78773? noredirect=1#comment173023_78773)
What I’ve already done:
comments
--------
id INT AUTO_INCREMENT PRIMARY KEY,
comment_text VARCHAR(1000) NOT NULL,,
type INT NOT NULL,
user_id INT NOT NULL, #chave estrangeira para usuário que postou o comentario.
product_id INT NOT NULL, #chave estrangeira para o produto a qual os comentários se referem.
posted_to INT #fiquei com dúvida porque uma resposta é postada para uma pergunta mas uma pergunta não é postada para ninguém.
date_posted DATE
What information will be recorded on
posted_to
? Do you have any specific questions? If I understand it seems to be all right. Some of these rules will obviously be guaranteed in the code and not in the modeling.– Maniero
would be an integer for the product id or question
– Ricardo
So what do you want to know? If it’s all right?
– Maniero
@bigown would like my modeling to cover the 6 points cited in the question and remedy my doubts I posted in modeling (it is possible that others arise so sanitize these)
– Ricardo
Item 4 I don’t quite understand, someone could just post an answer about something that wasn’t asked, is that it? Item 6 depends on the application to be developed and not on database modeling.
– gabrieloliveira