Wednesday, March 7, 2012

Multiple column primary key

Hi,
I'd like to know what is a good reason to use a primary key on more
than one field. In a many-to-many relationship, where I have these
tables :
ITEMS
item_id (pk)
...
...
PROPS
prop_id (pk)
...
...
ITEMS_PROPS
item_id
prop_id
For the table ITEMS_PROPS, is it a good idea to use a primary key on
both fields? Or is it better not to have any primary key at all?
Thanks a lotIt the table is truly many-to-many, then you must include both fields in the
primary key unless you create a surrogate key (which I do not recommend for
this situation). I would strongly discourage not having a primary key on
the table. In fact, for this situation, I can't imagine why you wouldn't
want one.
Regards,
John Opincar
"ibiza" <lambertb@.gmail.com> wrote in message
news:1154876795.909121.193220@.m73g2000cwd.googlegroups.com...
> Hi,
> I'd like to know what is a good reason to use a primary key on more
> than one field. In a many-to-many relationship, where I have these
> tables :
> ITEMS
> item_id (pk)
> ...
> ...
> PROPS
> prop_id (pk)
> ...
> ...
> ITEMS_PROPS
> item_id
> prop_id
> For the table ITEMS_PROPS, is it a good idea to use a primary key on
> both fields? Or is it better not to have any primary key at all?
> Thanks a lot
>

No comments:

Post a Comment