如何在数据库中维护博客评论 [英] How blog comments are maintained in database

查看:71
本文介绍了如何在数据库中维护博客评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友

我正在开发一个网站,用户可以在其中发布他们的评论.我想知道如何将这些注释保存在数据库中.

我正在考虑为每个使用ALTER命令输入注释的用户动态地向数据库表中添加一列,然后显示用户注释,从数据库表中获取该行,然后依次显示每一列.

这是实现我想要做的正确方法吗?

任何指导都将对我有很大帮助.

Hello Friends

I am developing one site where users can post thier comments. I wanted to know how to save these comments in database.

I was thinking to add one column dynamically into database table for each user entering comment using ALTER command and then to display the user comments, get the row from the database table and then display each column sequentially.

Is this a proper approach to achieve what I wanted to do?

Any guidence will be a great help to me.

推荐答案

为什么要麻烦做所有这些事情?为什么不只具有包含以下列的评论表:userId,blogPostId,日期时间?
Why bother doing all that? Why not just have a Comments table with these columns: userId, blogPostId, date-time?


嗨Nishant
感谢您的答复,但它没有回答我的问题,如何保存针对任何特定博客文章输入的所有评论.
博客文章的内容以blogPostId作为主键保存在数据库表"blogs"中.但是我在努力了解如何以及在何处保存用户针对此特定博文输入的评论.

对此的任何帮助将不胜感激.
Hi Nishant
Thanks for your reply but it didnt answer my question, how to save all the comments entered for any specific blog post.
The blog post contents are saved in the database table "blogs" with blogPostId as the primary key. But I am struggling to know how and where to save the comments entered by user for this specific blog post.

Any help on this will be appreciated.


这篇关于如何在数据库中维护博客评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆