[PHP-DB] Suggest Table Structure

2001-07-05 Thread kachaloo

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 table ?

Thanks in advance,
Vishal

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Suggest Table Structure

2001-07-05 Thread Sandis Jerics

Hi!

It's exactly what i'm doing right now - each article may have
many pictures, many authors, belong to many categories(sections),
can be translated in some languages, etc. :)
Sorry, i havent much time to explain your example, just paste mine
here.. Perhaps you'll got the idea!

CREATE TABLE articles (
  id int(11) NOT NULL auto_increment,
  title_lv varchar(255) ,
  title_ru varchar(255) ,
  title_en varchar(255) ,
  refs_lv tinytext ,
  refs_ru tinytext ,
  refs_en tinytext ,
  intro_lv text ,
  intro_ru text ,
  intro_en text ,
  cite_lv text ,
  cite_ru text ,
  cite_en text ,
  text_lv longtext ,
  text_ru longtext ,
  text_en tinytext ,
  author_desc_lv text ,
  author_desc_ru text ,
  author_desc_en text ,
  phone tinytext ,
  fax tinytext ,
  email tinytext ,
  web tinytext ,
  datetime datetime NOT NULL DEFAULT '-00-00 00:00:00' ,
  active int(1) NOT NULL DEFAULT '1' ,
  counter int(11) NOT NULL DEFAULT '0' ,
  PRIMARY KEY (id)
);

CREATE TABLE articles_images (
  id int(11) NOT NULL auto_increment,
  article int(11) NOT NULL DEFAULT '0' ,
  file varchar(255) NOT NULL DEFAULT '' ,
  text_lv tinytext ,
  text_ru tinytext ,
  text_en tinytext ,
  url tinytext ,
  PRIMARY KEY (id),
  UNIQUE file (file)
);

so, the data about images contained in this second table,
which is linked to the main table articles by the article id.

then i join these tables like this:

SELECT
  ...
FROM
  articles, articles_images
WHERE
  articles_images.article = articles.id


Hello kachaloo,

Thursday, July 05, 2001, 12:00:43 PM, you wrote:

k Hi guys,
k I am making a table which will store articles for a site
k and the feilds are :

k ID int(6) NOT NULL auto_increment,
k CATEORY varchar(10) NOT NULL DEFAULT 'EVENTS' ,
k HEADING varchar(30) NOT NULL DEFAULT '' ,
k BODY longblob ,
k PICTURE longblob ,
k KEYWORD varchar(30) NOT NULL DEFAULT '' ,
k FILENAME varchar(50) ,
k FILESIZE varchar(50) ,
k FILETYPE varchar(50) ,
k PRIMARY KEY (ID),
k UNIQUE ID (ID)


k But now I noticed some of the articles will have more than one
k picture... so how do I structure my table ?

k Thanks in advance,
k Vishal


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Suggest Table Structure

2001-07-05 Thread Roger Ramirez

Make a table for pictures.  Something simple that has an id and your picture
then in your article table you just change your picture field to your
picture id field.  You may want to do the same thing with category and any
other field if you notice that the article belongs in multiple categories.

- Original Message -
From: kachaloo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 05, 2001 5:00 AM
Subject: [PHP-DB] Suggest Table Structure


 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 table ?

 Thanks in advance,
 Vishal

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Odp: [PHP-DB] Suggest Table Structure

2001-07-05 Thread Bartek Pawlik

The best way is to create extra table storing only pictures:
CREATE TABLE PICS
ID_PICS int(x) NOT NULL auto_increment,
ID int(6) NOT NULL auto_increment [[foreign key from main table]]
PICTURE longblob,

Then you will be able to select pictures to certain article:
SELECT picture from PICS WHERE ID = 'give article ID'

Bartek Pawlik
Bimex-Boellhoff

- Original Message - 
From: kachaloo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 05, 2001 11:00 AM
Subject: [PHP-DB] Suggest Table Structure


 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 table ?
 
 Thanks in advance,
 Vishal
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 




-- 

Jedzisz konno?
Ten konkurs jest dla Ciebie! [ http://konkursy.onet.pl/emarket2/ ]