[lug] Learning about databases

socket at peakpeak.com socket at peakpeak.com
Thu Jan 6 14:08:46 MST 2000


Hi, everyone.

In the time I've got before spring semester starts, I'm trying to
learn something about relational databases-- it's the most significant
gap in my computer knowledge these days.  I dropped by Barnes and
Noble, browsed through some SQL books and the O'Reilly MySQL and mSQL
book, and am still a little fuzzy on some points.  Perhaps someone
could point me to a good online tutorial and reference?

Here's the issue: it seems that a lot of relationships I'd want to
represent aren't as simple as a one-to-many relationship. I've got a
library of books, for example, and might want to represent the genres
in each book.  It seems like it'd be pretty simple: the book table
would have a key into a genre table.  But a book might have more than
one genre-- it could be both mystery and sci-fi.  And turning the
relationship around, one genre contains many books, but two genres
could overlap.

I was thinking this would be represented easiest with intermediate
tables.  A book would point to the table that represents its specific
combination of genres, which would have a key pointing to a genre list
table.  But that would involve a table containing nothing but primary
and foreign keys, which seems a huge waste...  I have a number
relationships of this sort that I'd like to represent.  The best way I
can describe this is a many-to-many relationship, and I'm a little
lost on where to go now.

What's the appropriate way to represent such relationships (keywords,
genres, etc.) with mysql?

--
Chris Riddoch                  socket at peakpeak.com
Will provide pseudo-insightful commentary for food
                   http://www.peakpeak.com/~socket

GPG key 1024D/234551DC 1999-07-15 Chris Riddoch <socket at peakpeak.com>
Key fingerprint = 7AAF 5815 837C 070C 6C70  8A15 EFD2 5860 2345 51DC




More information about the LUG mailing list