"Summasummarum" <Su***********@hotmail.com> wrote in message
news:3f*********************@dtext02.news.tele.dk. ..
John Gilson wrote: Regards,
jag
Thanks for your suggestion. Interesting. I havent really thought of the
solution like that. Suppose it was given that theres allways 1 - and only
one - thumbnail pr Image (And vice versa)...would I then violate any "rules"
if I make a table like this:
CREATE TABLE Images
(
thumbnail_image_name VARCHAR(25) NOT NULL PRIMARY KEY
full_image_name VARCHAR(25) NOT NULL
)
?
To honest I dont like the above. Suppose the requirements changes and 2
thumbs pr Image is required...I kinda like the approach like this:
CREATE TABLE Images
(
image_id INTEGER NOT NULL PRIMARY KEY
image_name VARCHAR(25) NOT NULL
)
CREATE TABLE Image_Type
(
image_type_id INTEGER NOT NULL PRIMARY KEY
image_type INTEGER NOT NULL
)
CREATE TABLE Image_type_images_relations
(
image_type_relation_id INTEGER NOT NULL PRIMARY KEY
image_id INTEGER NOT NULL REFERENCES Images (image_id)
image_type_id INTEGER NOT NULL REFERENCES Image_Type (image_type_id)
)
In the above....Image_Type.image_type would then be an integer say 1 for a
thumbnail, and 2 for a big Image.
This way I think I am ready for future upgrades on the functionality...What
do you say about this approach?
/Summa
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27-11-2003
The reasoning behind my suggestion was the following:
1. An Images table representing each image, regardless of size or use.
So each image has a row in this table with any information intrinsic to
that image.
2. An ImageThumbnails table representing the relationship of one image
being a thumbnail of another image. Note that this table would allow
multiple thumbnail images associated with a given larger image. It will
also represent the case where image I2 is a thumbnail of image I1 and
image I3 is a thumbnail of I2, that is, I2 is smaller than I1 and I3 is smaller
than I2.
3. An ImageCategories table to represent groups of images, e.g., images I1,
I2, and I3 are part of the Autumn group. Obviously, an image can be in
more than one group.
For example, to get all full and thumbnail image pairs for the Autumn
group, one would query
SELECT IC.image_category_name,
IT.full_image_name,
IT.thumbnail_image_name
FROM ImageCategories AS IC
INNER JOIN
ImageThumbnails AS IT
ON IC.image_category_name = 'Autumn' AND
IC.thumbnail_image_name = IT.thumbnail_image_name
This, intuitively, seems to model the problem directly and naturally.
Regards,
jag