Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help for advanced SQL query
Gene, Spencer, et. al.
In Gene's original post he said that there was a many to many relationship between Object and Map. This prompted Daniel to observer that a third table to resolve the many to many was required.
If you have a many to many relationship without the third table it is "unresolved" and it violates the relational model... (somehow... don't ask me to go re-read Dr. Codd). If you join Object to Map directly, not through the intersection, you will get a sort of cartesian product. If that's what you're looking for then I've missed the point, and you needn't read the rest of this.
Gene says that there is a third table related to by the cluster IDs. I thought the cluster_id might fit in here somehow, but it doesn't have the foreign keys back to the two tables. If you'll look at the my PowerPoint slides there is working SQL that demonstrates the implementation of a many to many where a song can be on more than one album, and (of course) an album can have more than one song.
Its at www.laoug.org in the speaker presentation library. The file is DBA_music.zip.
Best!
Randall
Spencer <spencerp_at_swbell.net> wrote in message
news:B7ER6.154$Na6.10085_at_nnrp1.sbc.net...
> "gene" <usenet_at_smalltime.com> wrote in message
> news:9a95c0dd.0105311344.35eed2b7_at_posting.google.com...
> > "Randall Roberts" <randall_at_filer.org.nospam> wrote in message
news:<3b13099e_1_at_news.pcmagic.net>...
> > > Yes, as Daniel said, you have to resolve a many to many relationship
with a
> > > third table, which he and I call an intersection entity... but which
I've
> > > heard called a "join table", "resolution table", and a couple of other
> > > things in my career.
> > >
> >
> > Thanks for your replies. There actually is a third table (alluded to
> > by the cluster_ids), though it seems different from the third table
> > that you're describing. Here is a simplified description of the
> > tables:
> >
> > table OBJECT
> > ------
> > object_id (PK)
> > name
> > cluster_id (FK)
> >
> > table MAP
> > -----
> > map_id (PK)
> > position
> > source
> > cluster_id (FK)
> >
> > table CLUSTER
> > -----
> > cluster_id (PK)
> > name
> >
> > If I were to create an additional table directly relating the maps and
> > the objects:
> >
> > table OBJECT_MAP
> > ------
> > map_id (FK)
> > object_id (FK)
> >
> > it would just be the same product of the two tables as I get by doing
> > the join, or am I missing something?
>
>
>
>
>
>
>
>
>
>
>
>
>