저는 두 개의 스키마를 가지고 놀고 있는데 어느 것이 더 확장 성이 좋은지 결정할 수 없습니다. 이 스키마는 Q & A 용이며 MySQL에 내장되어 있습니다. 사람들은 질문/답변 및 좋아요/싫어하는/좋아하는 질문 및 답변을 게시합니다. 질문에는 여러 가지 답변/좋아요/싫어요가있을 수 있으므로 답변을 드릴 수 있습니다. 두 스키마 중 어느 것이 더 확장 성이 있습니까?
두 스키마 조인의 같은 번호가 필요합니다 사용자에게 질문을 읽으려면,하지만이 다르게 처리됩니다 조인 :스키마 1
questions(id, title, body, userId)
questionLikes(id, questionId, userId)
questionDislikes(id, questionId, userId)
quetionComments(id, questionId, body, userId)
answers(id, questionId, body, userId)
answerLikes(id, answerId, userId)
answerDislikes(id, answerId, userId)
answerComments(id, answerId, userId, body)
favourites(id, questionId, userId)
이 개발 쉽게, 더 정규화에게 를위한, 그러나 확장 성? 반복되는 정보가 많은 것 같습니다. 다음은 질문 (우리가 그와 같은/싫어하는 활동을 포함 할) 사용자에게 있습니다 잡기 위해 순서를 가입
select question
join answers
join questionLikes
join questionDislikes
join questionComments
join favouites
join answers to answerLikes
join answers to answerDislikes
join answers to answerComments (multiply answer joins by number of answers)
스키마 2
posts(id, postTypeId, userId, title, body)
postTypeId(id, postType)
comments(id, postId, userId)
votes(id, voteTypeId, userId)
voteTypeId(id, voteType)
이 덜 정규화 된 컴팩트 그것처럼 보인다 자체 조인 및 기타 개발 문제 (조건부 유효성 검사)를 사용하여 목에 고통이 더 잘 확장 될 수 있습니다. 질문을 잡기위한 가입 순서는
select question and its answers in the same read using where @id for question, and @questionId for answers; each row, join the following:
join votes on as likes on voteType 1
join votes as dislikes on votetype 2
join comments
join favouites (multiply joins by number of rows)
그래서 더 나은 확장 기능은 무엇입니까? 조인이 필요 없도록 몇 개의 필드를 추가하여 저장할 수 있다는 것을 알고 있습니다. 하지만 둘 다 같은 수의 조인이 필요하며 마음을 가릴 수 없습니다.
질문을 많이 읽지는 않았지만 왜 questionLikes와 questionDislikes에 대해 2 가지 다른 테이블을 사용합니까? 그리고 나는 같은 말을 당신에게 더 적용 할 수 있다고 생각한다. –
질문과 대답은 서로 다른 객체이므로 동일한 ID를 가질 수 있습니다. – Mohamad