In creating an application that would require a voting system similar to that of StackExchange or reddit, I want to know how the database tables should optimally be structured.
So far, I have something planned out like this:
Vote(UserID[PK], ContentID[PK], IsLike)
I had planned that the
ContentID(the entity being "liked") would be a composite primary key. This would make it so that I can tell which users have already "liked" certain content. The
IsLike field would determine whether the like/vote was positive or negative(like or dislike).
Also, could the composite primary keys be foreign keys linking to their respective tables (UserID --> User table, ContentID --> Content table) or is there something else I would have to do to make sure this would work?
Would this be an adequate way to store information about which users have liked certain content? Any suggestions welcome.