CodeIgniter Forums
Ideal structure for categories in blog - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Ideal structure for categories in blog (/showthread.php?tid=37754)



Ideal structure for categories in blog - El Forum - 01-19-2011

[eluser]Michal1[/eluser]
Hi,

I am trying to figure out what is the best structure for categories in blog system.
Lets say I want to be able to create new categories in my admin panel and assign articles into them.

I thought that the best way would be have a table

"articles" which would have rows like "id" "content" "category id"

then I would have a new table called "category" which would have rows like "category id" "name of category".

Is it a right and easy approach or is there some better and easier way?

Thanks


Ideal structure for categories in blog - El Forum - 01-19-2011

[eluser]Unknown[/eluser]
Maybe it might help taking a look at other blogs ? Wink


Ideal structure for categories in blog - El Forum - 01-20-2011

[eluser]Cristian Gilè[/eluser]
What if your article could have more than one category?

Code:
ARTICLE table:
-id
-title
-text

CATEGORY table:
-id
-name

ARTICLE_CATEGORY table:
-id
-article_id
-category_id


Cristian Gilè


Ideal structure for categories in blog - El Forum - 01-20-2011

[eluser]InsiteFX[/eluser]
Do not forget that you may also have comments for articles!

Maybe tags also.

InsiteFX