473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Suggestions for a small database layout...Very simple

Hi ng,

I need some input/suggestions for a very small layout.

The situation: Some groupings of thumbnails. For every picture (thumbnail)
there is a "big" picture. Thats it basically :) On the front the scenario is
this:

A user clicks "Autumn". The user is presented with the "Autumn" thumbnails.
If he click a thumbnail, the corresponding big image is displayed. Well, u
get the picture :)

Hoe is this most efficiently implemented in table-layout? I mean....do I
create a table called "images" and have a column called "is_thumb"? Or do I
better make 2 tables...Or better make a "relation/type" table too?

--
Thanks,
/Summa
Jul 20 '05 #1
4 2209
"Summasummarum" <Su***********@hotmail.com> wrote in message
news:3f*********************@dtext02.news.tele.dk. ..
Hi ng,

I need some input/suggestions for a very small layout.

The situation: Some groupings of thumbnails. For every picture (thumbnail)
there is a "big" picture. Thats it basically :) On the front the scenario is
this:

A user clicks "Autumn". The user is presented with the "Autumn" thumbnails.
If he click a thumbnail, the corresponding big image is displayed. Well, u
get the picture :)

Hoe is this most efficiently implemented in table-layout? I mean....do I
create a table called "images" and have a column called "is_thumb"? Or do I
better make 2 tables...Or better make a "relation/type" table too?

--
Thanks,
/Summa


-- A row for each image, whether full or thumbnail
CREATE TABLE Images
(
image_name VARCHAR(25) NOT NULL PRIMARY KEY
)

-- Relationship between full image and its thumbnail
-- Assume a full image can have multiple thumbnails
CREATE TABLE ImageThumbnails
(
full_image_name VARCHAR(25) NOT NULL
REFERENCES Images (image_name),
thumbnail_image_name VARCHAR(25) NOT NULL PRIMARY KEY
REFERENCES Images (image_name)
)

-- A thumbnail could be found in multiple categories
CREATE TABLE ImageCategories
(
image_category_name VARCHAR(25) NOT NULL, -- example: 'Autumn'
thumbnail_image_name VARCHAR(25) NOT NULL
REFERENCES ImageThumbnails (thumbnail_image_name),
PRIMARY KEY (image_category_name, thumbnail_image_name)
)

Regards,
jag
Jul 20 '05 #2
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
Jul 20 '05 #3
"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
Jul 20 '05 #4
John Gilson wrote:
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.


Yes...you are right. It seems more intuitive..I'll have a go at it monday.
Thanks for your thoughts..

/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
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jason | last post by:
Hello everyone. I have been given the task of working with PHP and MySQL at my company, to development some methods for our future use. The problem is, I have very little experience with PHP,...
6
by: JW | last post by:
I'm displaying product thumbnails with brief descriptions on web pages. Clicking on the product does a javascript popup with larger image and detailed description info passed to the javascript...
2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
12
by: Simon Harvey | last post by:
Whato chaps, I work (or am hoping to work! :) for a company that specialises in the following: - Localisation of media - including software, manuals, literature and training material. -...
5
by: rob | last post by:
Hi to all. I am pretty new to using Access and am having a problem I hope someone can help me with. I want to access a MS-Access database from a web page. I have managed to get it "sort" of...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
7
by: Daniel Kabs | last post by:
Hi there, for a long time I've been using tables to layout elements on a web page. Example: Say we have a 2x2 table and I'd like to put text (left aligned) and buttons (right aligned) in the...
6
by: GiJeet | last post by:
Hello, I'm working on a winforms app that will be used in stores in different states and each state can have different data capture requirements. I want to create a base form for for all the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.