Re: mysql question
| From: | Cristian MARIN | Date: | Wed, 09 Jul 2003 08:29:10 +0000 |
| Subject: | Re: mysql question | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-20742@lists.php.net to get a copy of this message | ||
Try to make a many-to-many design :
Create a table 'images_img' with id_img, name_img, accession_img ... for the
images
Create a table 'categories_ctg' for the categories with id_ctg, name_ctg,
description_ctg ...
Create a table for unifing this two imgtoctg_itc with id_itc, idimg_itc,
idctg_itc
In the image insert the image id_img=1, name_img="picture1.jpg",
accession_img="1031-LH0152"
Insert into categories the id_ctg=1, name_ctg="Military Posters" ...
id_ctg=3, name_ctg="Ontario Regiment"
Insert the links between the two in the imgtoctg_itc like this
id_itc=1 ;The id of the record
idimg_itc=1 ; The image id
idctg_itc=1 ; The category id
id_itc=1 ;The id of the record
idimg_itc=1 ; The image id
idctg_itc=2 ; The category id
id_itc=1 ;The id of the record
idimg_itc=1 ; The image id
idctg_itc=3 ; The category id
In this case the picture is fit in all three categories.
Now you have to read into the mysql manual how to use the left join, right
join, inner join to retrieve all the records you need from both tables
images_img and categories_ctg by passing throw the imgtoctg_itc
Hope this answer your question
--
-------------------------------------------------
Cristian MARIN - Developer
InterAKT Online (www.interakt.ro)
Tel: +4021 312.53.12
Tel/Fax: +4021 312.51.91
cristic@interakt.ro
"H Marc Bower" <hmbower@cogeco.ca> wrote in message
news:00aa01c34594$26c0c5f0$0b01a8c0@canetix...
I know this isn't the mysql area... but many of you seem very knowledgeable
in this area and I would appreciate your input...
What kind of field setup should I create if I want a field which will,
essentially hold several distinct items, but never a set number of them? I
am going to be selecting these items (or the relational pointers to them)
from a multi-select list (ie. this image belongs in the following
categories). After that, I will need to output the contents of this field to
an array. That part I know how to do using php as long as it's a big
string, but I am guessing there is a better way to do this. From the
manual, it seems that a SET field would work, but I'd need the SET to be the
contents of a field from another table.
For example, I have an image with an accession number of 1031-LH0152. It
will fit in the categories of "Military Posters", "McLaughlin - Colonel
Robert Samuel", and "Ontario Regiment". How do I get one field to hold all
of the categories, and then what is the most efficient way to then transport
that into an array with php?
Thank you for the more-elaborate-than-just-php assistance.
Marc