I'm currently in the process of building another generic Blog style website, and I got to thinking. Where I usually use a separate table for Posts
and another for Comments
and then join them using FK's. I began to wonder, are they really worthy of separate tables?
For example properties they both share include:
- ID (int)
- Title (string)
- Body (text)
- Poster (FK)
- Created At (Datetime)
- Updated At (DateTime)
- Likes/Dislikes(ints)
- Etc..
One Post
Has(optional) Many Comments
,Many Comments
have one Post
, but also One Comment
, may also have many Comments
.
Now would it make more sense. For a table to contain both, Comments and Posts, and self reference them from within? Having a separate lookup table for containing what each type of entity is.
Then however, if a Post is a Comment, and a comment is no different to a post. Except for in a view context, should posted Images also be contained within the same table? As these to, can have likes/comments/name etc.
Question in short: Do blog Posts and Comments belong in the same table?
Aucun commentaire:
Enregistrer un commentaire