If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Design including Image sets

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-09-07, 10:36
Jackson77 Jackson77 is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
Design including Image sets

Hey guys,

I'm currently in the design stage of a database, and have a question of how the keys should be set up in two of my tables.

I have an Orders table, which is related to a Customers table, and also to an Images table.
The orders table has OrderID (PK), CustID (FK), and ImageSetID (PK)

The ImageSetID field joins to the Images table which contains ImageSetID (FK), ImageID (PK), and ImagePath

Now, I plan to have multiple images for each order, which all will have a common ImageSetID, and each individual image will have an Unique ImageID.
And I plan to store all the image paths in one table.

Example:

ImageSetId - ImageID - ImagePath
---------------------------------------------------
001 - 001 - C:\Pictures
001 - 002 - C:\Pictures
002 - 001 - C:\Pictures
002 - 002 - C:\Pictures
002 - 003 - C:\Pictures

Now, am I wondering.. Am I able to Have a unique ImageID, relating to the ImageSetID?
But, while still using the same ImageID, but for a different ImageSetID..

The way I plan to use input the data, is by creating a new order, then importing images into that order, but for the ImageSetID to stay the same while I am in the same order, but for the ImageID to change.

If that is not possible, any there any suggestions to how to set that up?

Anything would be appreciated, thank you.
Reply With Quote
  #2 (permalink)  
Old 07-09-07, 10:57
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
If you want ImageSet 001 and ImageSet 002 both to contain an Image with ImageId of 001 then you need to use a composite key in Images:
Code:
create table images
( ImageSetId references ImageSet(ImageSetId)
, ImageId integer
, ImagePath varchar(100)
, primary key (ImageSetId, ImageId)
);
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 07-11-07, 03:37
Jackson77 Jackson77 is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
Thank you. It works perfectly.
Much appreciated.

Last edited by Jackson77; 07-11-07 at 04:13.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On