简体   繁体   中英

check database design for a blog application

I am creating a blog application - where multiple users can publish, share and like blogs.

I've created an outline of the database but I am not sure if its the right way. I do not understand how to go about foreign key inspite of reading about it.

Can someone help me in solving these issues. Some questions that are in my mind are :-

- should the articles(blogs) details be stored in both 'Table Articles' and 'Table Share' at the time a user publishes an article. Will this help me in writing a php script in showing only the latest and shared articles on top of the page

- should articleid be stored in all tables?

Following is an outline of my database

Users

Table users

-userid
-email
-name
-password
-date_of_registration

Articles

Articles have a title and a description. Later I have plans to add images, but not now. A user can post an article after registration or logging in. Latest articles are shown on top of the page (along with shared articles).

Table Articles

-articleid
-userid
-title
-description
-datetime 

Comments

Users should be able to comment on articles from other users + the person who posted should also be able to comment

Table comments

-commentid
-articleid
-userid
-comment
-datetime

Share

Users should be able to share articles they like. The person who posted an article cannot share it again. If an article has been shared it should come on top of all articles (along with the latest articles).

Table share

-articleid
-userid (the person who shared it)
-datetime

Like

Users should be able to like any article.

Table Like

-articleid
-userid (the person who clicked on the like button)
  1. make sure you hash the user password and store a salt.

  2. pick a common date naming scheme. "action"_at is a good one. For example, "registered_at" or "created_at". you should use underscores between words for maximum compatibility and legibility.

  3. are you sure a user needs to login to comment? many blog systems let people comment w only an email address. No comment threads allowed?

  4. you could add a "created_at" field to the like table. make sure you have a primary key on both article_id and user_id

  5. How does sharing work? With whom are they sharing?

Otherwise, a good start!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM