简体   繁体   中英

Database design for a blog with separate tables for users, comments and posts in cakephp

I have to do an assignment of creating a blog with users who can post posts and also comment on the posts. Should I create three tables for users, posts, comments with everyone in each table having a unique id?

And do I need a foreign key field in my tables??

Thanks in advance..

Thought some research would be helpful as you would get more insight into how it works, a system for a basic blog system is pretty simple.

You would have the Post, User and Comment, each should have its separate Id and you would of course need foreign keys to link them together. An example would be:

users('id', 'username', 'password'),
posts('id', 'title', 'content', 'slug', 'user_id'),
comments('id', 'content', 'date', 'post_id', 'user_id')

Cake PHP's Book 1.3 has a good tutorial on this: http://book.cakephp.org/1.3/en/view/1528/Blog

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