Re: A Question On Many-To-Many Linking Table(s)

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 22 Sep 2002 20:23:00 -0700
Message-ID: <c0d87ec0.0209221923.42b0561b_at_posting.google.com>


aleatory_at_hotmail.com (aleatory) wrote in message news:<a68a4ee0.0209220745.4442210e_at_posting.google.com>... > Hi all,
>> According to some of the database books I have, they say that
many-to-many implies a linking table(s). <<

That is a terrible term; tables are either entities or relationships and not both. The term "link" is an old one we used for pointers, as in "linked list" and that low level concept has no place in a relational model.

>> Then I came up with the following linking table, but is this a good
approach to design the database? <,

Learn to post DDL instead of your own personal pseudo-code  

CREATE TABLE Comp_CD_Peform
(composer_id INTEGER NOT NULL REFERENCES Composers (composer-id),  upc DECIMAL (10,0) NOT NULL -- use industry standard codes

     REFERENCES CDs
 performer_id INTEGER NOT NULL REFERENCES Performers(performer_id),  PRIMARY KEY (composer_id, upc, performer_id));

Note that you have to have a key for a CREATE TABLE to be a table.   

>> What I would like to do is search for a composer and his or her
corresponding cds, or cds produced (performed) by certain performers. <<

Do an INNER JOIN from composers, cds and performers via this relationship table. Since the table is all key, it is in 5NF. Received on Mon Sep 23 2002 - 05:23:00 CEST

Original text of this message