views:

72

answers:

2

I have two quantities Cat A , CatB

Now the items in Cat A can belong to many items in CatB. and CatB will also have many Items from Cat A.

I thinking of having Table1 for Cat A , Table2 for CatB and Table C for relation ship.

with

PK-A  , PK-B

Is that correct.

How should i make my form in html so that user can select multiple values. Currently i am using select box

Any ideas?

+2  A: 

Yes, in a relational database, a relationship table with foreign key into the two tables being related many-to-many is indeed the right way to go.

In HTML, use <select multiple="multiple"> for a multiple-selection select.

It would be best to ask these two separate questions as two separate questions, btw!-)

Alex Martelli
A: 

What you are telling can be cleared if you can show the columns in the tables. If you are saying "items" from CatA belongs to CatB and vice versa, it seems CatA and CatB supposed to be in a single table and the "items" should be in a different table. Please review your normalisation steps.

Kangkan
@Kangkan, uh? As I read the questions, CatA could be e.g. "people" and CatB could then be e.g. "clubs" -- a person can belong to many clubs, a club can have many members -- typical many-to-many relationship, no normalization issues.
Alex Martelli
yes u r right Alex
Mirage
@Alex, in that case your approach is right. But what do you exactly mean by "a person can belong to many clubs"? Isn't it equivalent to "a club can have many members"? In that case there is a single relationship "Member" in between them.
Kangkan
@Kangkan, of course there's a single relationship (hence a single table), and it's many-to-many. How could "a club can have many members" be equivalent to "a member can be in many clubs"?! A pro *soccer* club can have many players (it had better have at least 11!-) but a players can only play for one club (League regulations!-) -- that's a many-to-one relationship (one club, many players).
Alex Martelli
@Alex thanks I got it now. I hope I have not bothered you too much!
Kangkan
@Kangkan, NP! I just wanted to make sure I understood what you were saying, that's all -- thanks for following up.
Alex Martelli