[nycphp-talk] Database, table, and column naming schemes
tedd
tedd at sperling.com
Tue Oct 6 13:55:52 EDT 2009
At 12:43 PM -0400 10/6/09, Dan Cech wrote:
>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:
That's a good point, but I still like having a "separate from data"
auto_increment index for all records. Besides adding one field to a
record, can you see any harm in that?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
More information about the talk
mailing list