Re: Categories like wordpress

From: Date: Thu, 01 May 2008 15:16:09 +0000
Subject: Re: Categories like wordpress
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-273781@lists.php.net to get a copy of this message
On May 1, 2008, at 743AM, Richard Heyes wrote:
Is this how its done or am I barking up the wrong tree?
You have multiple options: 1. Fully normalised, where you have three tables - one for your "articles", one for your categories and a link table.
This is the route that I would suggest, it's the most flexible and fastest to query. Just to expound a little... images table: - image_id - image_filename category table - category_id - category_name image_category_mapping table: - image_id - category_id Then when you want to get all of the images for a category: SELECT image_id, image_filename FROM images JOIN image_category_mapping ON images.image_id = image_category_mapping.image_id WHERE category_id = 10; Getting all the categories an image is in: SELECT category_id FROM image_category_mapping WHERE image_id = 42; It seems like more work than the route you described, but it's way more flexible, and as Richard pointed out, it's fully normalized. Brady

« previous php.general (#273781) next »