Hey guys,

Am a newbie here and need a little help.

Part of the database consists of two tables "events" and "categories" which
look like this

+-------------------+-------------------------+
 |  eventID       |     eventName     |
+-------------------+-------------------------+
 |       1           |     Event A          |
 |       2           |     Event B          |
 |       3           |     Event C          |
+-------------------+-------------------------+
Primary Key: eventID

+-------------------+-------------------------+
 |  categoryID  |   categoryName   |
+-------------------+-------------------------+
 |       1           |     Category A     |
 |       2           |     Category B     |
 |       3           |     Category C     |
+-------------------+-------------------------+

Primary Key: categoryID


The idea is that an event may have multiple categories and from what I've
read here (http://lists.mysql.com/mysql/171645), many-to-many relationships
in the database should be avoid.  According to the link and a couple of
others I found, I'm supposed to create a separate "events_categories" table
and make linkages using a Foreign Key.  Am not sure how to translate this to
a SQL query.  Can I get some help.

Thanks a million!

Regards,
Suren

Reply via email to