[nycphp-talk] Database, table, and column naming schemes
Kristina Anderson
ka at kacomputerconsulting.com
Tue Oct 6 12:49:06 EDT 2009
> Kristina Anderson wrote:
> > Exactly, the table would contain probably nothing more than a
primary
> > key autonumber field, the user id and account id in each row.
>
> Why do you need a separate primary key? The relationship is defined
by
> user id and account id.
>
> CREATE TABLE some_rel (
> user_id int(11) not null,
> account_id int(11) not null,
> some_attribute varchar(255),
> PRIMARY KEY (user_id,account_id)
> );
>
> I added the attribute column to illustrate that you can still identify
> the row like:
>
> SELECT some_attribute FROM some_rel WHERE user_id=X AND account_id=Y
>
> HTH,
>
> Dan
>
Dan,
As soon as I wrote this post I knew someone was going to bring that up
and you're entirely right!
Kristina
More information about the talk
mailing list