Re: Suggest Table Structure

From: Date: Thu, 05 Jul 2001 15:14:18 +0000
Subject: Re: Suggest Table Structure
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-56317@lists.php.net to get a copy of this message
Hi, you have to break your table in pieces and create tables for items that occur more than once. For example: CREATE TABLE articles ( ID int(6) NOT NULL auto_increment, id_category UNSIGNED INT REFERENCES category, HEADING varchar(30) NOT NULL DEFAULT '' , BODY longblob , ...) CREATE TABLE pictures ( ID int(6) NOT NULL auto_increment, PICTURE longblob , id_article UNSIGNED INT REFERENCES articles) CREATE TABLE category ( ID int(6) NOT NULL auto_increment, category varchar(30)) So, if you want to list all the pictures of the article 'Linux Rules!' you have to write a query like: SELECT heading, picture FROM articles, pictures WHERE pictures.id_article = articles.id AND heading='Linux Rules!' PS: A create the table category to illustrate how to put things in order with some normal forms. On Thu, Jul 05, 2001 at 02:31:55PM +0530, kachaloo wrote: > Hi guys, > I am making a table which will store articles for a site > and the feilds are : > > ID int(6) NOT NULL auto_increment, > CATEORY varchar(10) NOT NULL DEFAULT 'EVENTS' , > HEADING varchar(30) NOT NULL DEFAULT '' , > BODY longblob , > PICTURE longblob , > KEYWORD varchar(30) NOT NULL DEFAULT '' , > FILENAME varchar(50) , > FILESIZE varchar(50) , > FILETYPE varchar(50) , > PRIMARY KEY (ID), > UNIQUE ID (ID) > > > But now I noticed some of the articles will have more than one > picture... so how do I structure my talbe ? > > Thanks in advance, > Vishal > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#56317) next »