comments as normal nodes in database -
i not database expert. ask beginner. going design database i'm not sure if doing right or wrong in database designing. website should contain articles , posts , each post may have several comments. decided treat articles, posts , user profiles node. created table called "node" , each "node" has "content" text. thinking whether comment should treated "node" or should make different table "comment_nodes". looking efficient way.
so, in 1 word: ok treat comments normal nodes or not?
thanks
this called table inheritance, , it's not bad idea. example, in drupal, things "node".
the main advantage lets have foreign keys pointing different things (of same parent type).
i use class table inheritance in case. this:
node id node_post id pk fk node(id) title body node_comment id pk fk node(id) body post_id fk node_post(id) parent_comment_id fk node_comment(id)
anyways, google martin fowler on table inheritance , make sure understand implications.
if you're using php doctrine out inheritance.
i'd recommend postgres on mysql if going have nested comments postgres hierarchical querying better mysql.
Comments
Post a Comment