mysql - Implementation of Comments, Is there any best practice for this? -


I need to implement the comments feature on a custom coded social networking website.

What would be the best practice to implement it?

To create a global comment table, the comments need to be implemented on various pages like video, pictures, albums, etc. Collect comments on the basis of your comments type, along with fields, and on the necessary page.

  commentid int (10) userid int (10) comment_type ENUM ('video', 'image') comment varchat (200) parent int (10)  

Or are you making separate tables for each comment?

I will not do this in such a way that I will use sub-type on the other side.

  • Create a basic parent table named (for example) content (for example);
  • There are child institutions for video, pictures, albums, etc. Content;
  • The content in the comment is a foreign key of the ID.

There are three basic plans for applying subtypes:

  1. Create a separate table for each subtype;
  2. Create a table called Content with the subtitle of the video, album etc. along with the foreign key of the Contents ID. The content table also has a content type field, to indicate that the table is related to that record is; Or
  3. There is a bunch of optional (blank) columns to cover the subtues that put everything in a table on the name of the material. This is most suitable when storing sub-tape-specific information There is no difference in the required column.

If you comment on a related video or album in a table, what do you call Unique Arc for example

    < Li> The user (id, username, given name, surname,
  • image (id, url, height, width);
  • Video (id, e-mail address)
  • Album (id, album_id, photo_id); < >
  • Comment (id, author_i D, comment_data, comment, content_id);

Some notes:

  • submitter_id and author_id are foreign keys for User.id;
  • Image.id, Video.id and Album.id are all foreign keys for content. ID;
  • Content.content_type is one of "image", "video" or "album";
  • An album consists of one of the more photos stored in the image;
  • The joining table album links images to photos (multiple-to-many relationships);

Hope this is a bit Yes, it does.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -