|  | Posted by Jerry Stuckle on 06/25/06 03:14 
IchBin wrote:> Geoff Berrow wrote:
 >
 >> Message-ID: <1151197943.581310.88860@b68g2000cwa.googlegroups.com> from
 >> frizzle contained the following:
 >>
 >>> I'm building a music site with a mysql backend. It has a many to many
 >>> relational database.
 >>> I use this to match music genres with certain artists, to maintain the
 >>> possibility to add multiple genres to a singe artist.
 >>>
 >>> Now i've searched google, but can't find a solution on how to update
 >>> rows with checkboxes.
 >>> If an artist gets his genre updated as follows:
 >>> from
 >>>
 >>> - [_] classic
 >>> - [X] rock
 >>> - [_] ballad
 >>> - [X] 80's
 >>> - [_] 90's
 >>> - etc.
 >>>
 >>> to
 >>>
 >>> - [_] classic
 >>> - [_] rock
 >>> - [_] ballad
 >>> - [_] 80's
 >>> - [X] 90's
 >>> etc.
 >>>
 >>> wha t i wonder is how could i best create the backend. it would seem
 >>> inappropraite to run an update query for each possible box wether it's
 >>> checked or not.
 >>
 >>
 >> It depends how you have structured your db.  For a many to many
 >> relationship like this you ideally need three tables, one for artists,
 >> one for genres and one to link the two.
 >>
 >> In the case above you would start with two rows in the link table.
 >> Updating would require removing a row, though it may be simpler to
 >> remove them all and then write a new one.
 >>
 >>
 >>
 >
 > I do not think you need three tables. Genres is an adjective describing
 > either a song or the singer singer.  A Genre should be added to both
 > tables because each singer could have more that one Genre but one song
 > can only be one Genre. But then again one song can have multiple singers.
 >
 >
 > Thanks in Advance...
 > IchBin, Pocono Lake, Pa, USA http://weconsultants.awardspace.com
 > __________________________________________________________________________
 >
 > 'If there is one, Knowledge is the "Fountain of Youth"'
 > -William E. Taylor,  Regular Guy (1952-)
 
 
 I'd suggest you read up on "database normalization" and how it prevents the
 problems which can be caused by your method.
 
 Also, a song may have multiple genre's.  For instance - it could be "Rock" and
 "80's".  Or, depending on how it was played/sung, it could be "Country" or "Rock".
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |