If it's for a "linking table", you'd just have something like this:

CREATE TABLE linking_table (
    first_id INTEGER,
    second_id INTEGER,
    PRIMARY KEY (first_id, second_id)
);

For an n-m relationship, that's the only way to do it.

Dean Harding.

P.S. The syntax may be wrong, that's just off the top of my head, but
you get the idea - a primary key doesn't have to be on one field only,
it can be on as many as you need.

> -----Original Message-----
> From: Desmond Lee [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 28 July 2002 12:27 pm
> To: [EMAIL PROTECTED]
> Subject: help me out here guys... you gotta have a primary key
> 
> k....
> 
> This is seems ridiculous to me,.. but i'll let you tell me if i'm just
> being
> stubborn.
> 
> So, one of my associates has made a linking table (some people also
call
> it
> intersection table, cross tab table, but i believe that the propper
way to
> model a many to many relationship is via a "linking table"). in the
> linking
> table, there is no primary key defined. I believe that every table
must
> have
> a primary key. It is absolutely essential, otherwise you'll get tons
of
> problems including redundancy, and inconsistency. However, my
associate
> believes that our coding will ensure that such problems will be
avoided
> and
> that it's okay for a table to have no primary key defined. I totally
> disagree. Even if our code is perfect, a primary key must be defined.
> 
> So, am i correct in being concerned, or am i just being close minded?
> If, i'm totally wrong, in what situations is it a good idea, okay, or
> benificial to not have a primary key defined for a table?
> 
> 
> Thanks
> 
> Desmond
> 
> 
> (sql)
> 
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <mysql-unsubscribe-
> [EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to