views:

51

answers:

1

I have a simple table for a gallery. There are many galleries, each containing images - which may belong to multiple galleries.

Basically this is a 'cross table' with a sort order within that gallery.

CREATE TABLE [dbo].[GalleryXGalleryImage](
    [GalleryId] [int] NOT NULL,
    [GalleryImageId] [int] NOT NULL,
    [SortOrder] [int] NOT NULL CONSTRAINT [DF_GalleryXGalleryImage_SortOrder]  DEFAULT ((1)),
 CONSTRAINT [PK_GalleryXGalleryImage] PRIMARY KEY CLUSTERED 
(
    [GalleryId] ASC,
    [GalleryImageId] ASC
)

I need to edit this table within the database (no time to create a UI) but I need visual cues about which images are which to be able to put them in the correct order.

If I show WHERE GalleryId=13 and do a cross join on GalleryImages for GalleryId then I see a list, but of course I cannot actually edit this table because of the cross join.

I need to find a way to edit the GalleryXGalleryImage table but still see the names of each image. If this can't be done in enterprise manager (by somehow telling it to ignore the image name column) then I'm sure there must be some other tool to do this.

I'd rather not write a UI, or try to cut data back and forth from excel.

Edit: I actually meant inner join. I said 'cross' by mistake becasue i'd already mentioned cross table.

A: 

Your SortOrder column belongs on the Gallery table, not the GalleryXGalleryImage table. It applies to a gallery and not to paritcular images within that gallery.

Peter Ruderman
each gallery has the images in a different order. i have galleries for certain events and the images within the gallery have a sort order for that gallery. then i have more generic galleries where i want to feature the best of the best. there is also an additional 'SortOrder' on the Gallery table, but i defintitely need one on GalleryXGalleryImage also
Simon_Weaver
Then what does SortOrder on the GalleryXGalleryImage table mean exactly? It makes no sense to define a sort order for a single image. Can different images in the same gallery have different sort orders? If a gallery can have multiple sort orders, then the proper way is to define a separate GallerySortOrder table. Your problem is an improperly normalized database. Fix that and your original issue disappears.
Peter Ruderman