Re: help with simple db design
Posted by: H Yowza
Date: April 02, 2006 08:34PM

Ok here's what i've done:

I have a hobbies, member and memberhobby table

the Hobbies table has the following

Hobbie, char 255, 0
Hobbie_ID, int 11, PRIMARY KEY

MemberHobby:

Hobbie_ID, int 11, PRIMARY KEY ----> REF Hobbies Hobbie_ID
Member_ID, int 11, PRIMARY KEY ----> REF Member Member_ID

(both are primary keys in this instance, because many members can have many same hobbies so both have to be unique:

i.e. Sarah | Tennis
John | Tennis

Member:

Member_ID, int 11, PRIMARY KEY
Member_Name, char 255


Does that look OK?

Just having problem retreiving stuff:




mysql> SELECT GROUP_CONCAT(Hobbie_ID ORDER BY Hobbie_ID DESC SEPARATOR ', ') from Member, MemberHobby WHERE Member_ID = '23' Group by MEMBER_ID;

lists ervery hobbie for some reason :

+----------------------------------------------------------------+
| GROUP_CONCAT(Hobbie_ID ORDER BY Hobbie_ID DESC SEPARATOR ', ') |
+----------------------------------------------------------------+
| Tennis, Hockey |
+----------------------------------------------------------------+

When the memberhobbie contains:


+-----------+-----------+
| Hobbie_ID | Member_ID |
+-----------+-----------+
| Hockey | 23 |
| Tennis | 25 |
+-----------+-----------+



Edited 3 time(s). Last edit at 04/02/2006 08:46PM by H Yowza.

Options: ReplyQuote


Subject
Written By
Posted
April 02, 2006 05:02AM
April 02, 2006 11:14AM
April 02, 2006 07:37PM
April 02, 2006 08:01PM
Re: help with simple db design
April 02, 2006 08:34PM
April 02, 2006 09:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.