I have what I believe to be a good book on database desgin (Essence of Databases by Fred Rolland) and I have also read through this website; http://goo.gl/TxDq4. Both of these resources are great, but they use very structured examples involving customers and companies interacting.
I am trying to create a database that will contain references to hundreds of photographs. As part of the project I am working on I hope to allow the user to create slideshows. If I understand the theory correctly, this represents a “many to many” relationship, which I need to break with a “joining table”.
What I can’t get my head around is what this joining table should look like, or what function it actually performs. My feeling is that the joining class I’m trying to create is more nebulous than having an “Order Line” or such like. My first draft, with a joining class, looks like this: http://img28.imageshack.us/img28/2756/photodb2.png
And then I just get confused about what I’m actually trying to achieve with the joining class. A Slideshow can contain many Photographs and a Photograph can appear in many Slideshows.
With the joining class, SlideshowView, I think I’m creating an “instance” of a Slideshow, where that specific Slideshow can only contain one instance of any one Photograph. In this case, I’m confused about the relationship between the SlideshowView and Slideshow!
In fact, looking over this again, my diagram makes even less sense… A SlideshowView can only contain one Slideshow, but a Slideshow can be part of more than one SlideshowView? The trouble is, if I make the relationship one-to-one, doesn’t that make SlideshowView redundant?
When I think about this from a programming perspective, I would simply ask the user to select a Slideshow that would contain many Photographs, in which case, what is the difference between Slideshow and SlideshowView? Am I over-complicating this? It’s really “twisting my melon”! Any advice on how to proceed with this would be gratefully received.
For a many-to-many relationship, your left-hand relationship is the wrong way round. One photograph can appear in many slideshows, but you have drawn this the other way round – in effect, you have modelled a one-to-many with an unnecessary middle table, which is why it seems wrong to you. Slideshow and SlideshowView are indeed effectively the same the way you have drawn your diagram.
The user will never “see” the middle, linking table. (S)he will select multiple photographs for a slideshow; for each of these, a row goes in the linking table to link those photographs to the new slideshow, without precluding them also appearing in other slideshows. To the end user, only photograph and slideshow are visible. I’d call the linking table SlideshowPhotograph personally. Here are the ID values for three photographs and two slideshows, showing photo 109 appearing in both slideshows.