Yii Framework Forum: Design Database - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Design Database Rate Topic: -----

#1 User is offline   Manee 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 103
  • Joined: 23-September 12

Posted 09 March 2013 - 11:27 AM

hi all. i'm designing below db with INNODB, is relation of that correct? this is small and simple blog system
1) post can be have any category
2)user can have and create any post

Posted Image
Posted Image
Posted Image
0

#2 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 586
  • Joined: 27-December 10
  • Location:china

Posted 10 March 2013 - 02:54 AM

user has-many blog
blog belong-to a user
blog belong-to a category

user(id,....);
blog(id,uid,cate_id,....); // this is just suitable for a category has many blog and blog belong to a category--not many categories
category(id,title....);

if you want there exists "many-many" relations between blog and category ,you should introduce a bridage table :
category(id,title....) , category_blog(cate_id,blog_id);

This post has been edited by yiqing95: 10 March 2013 - 02:56 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users