Designing a database for a basic forum similar to reddit

Viewed 57

So I am trying to design a forum similar to reddit where there will be users, threads, and comments. Here is the database design I have come up with:

Users table

id              :  int
username        :  text
hashed password :  text

Threads table

id              :  int
date            :  timestamp
author          :  int - userID foreign key
title           :  text
description     :  text
deleted         :  boolean

Comments table

id              :  int
date            :  timestamp
author          :  int - userID foreign key
text            :  text
deleted         :  boolean
threadID        :  int - threadID foreign key (required)
commentID       :  int - commentID this is a reply to (this is only if the comment is a reply to another comment)

ThreadVotes table

id              :  int
userID          :  int - userID foreign key
threadID        :  int - threadID foreign key
voteStatusID    :  int - voteStatusID foreign key

CommentVotes table

id              :  int
userID          :  int - userID foreign key
commentID       :  int - commentID foreign key
voteStatusID    :  int - voteStatusID foreign key

VoteStatus table

id - int        :  status - text
0               :  "down"
1               :  "neutral"
2               :  "up"

Does this look right? I am new to databases / SQL

0 Answers
Related