NYCPHP Meetup

NYPHP.org

[nycphp-talk] Database, table, and column naming schemes

tedd tedd at sperling.com
Sun Sep 13 20:28:02 EDT 2009


At 11:56 AM -0400 9/13/09, Matt Juszczak wrote:
>>Plus, if you're going to be consistent with that "mistake", then 
>>your naming should be:
>>
>>customer_customer
>>customer_account
>>customer_account_type
>
>I disagree.  I wasn't trying to create "customer" as a prefix.  I 
>was simply renaming the tables based on the one:many relationships I 
>have inside the tables.
>
>account
>account_type
>customer
>
>since customer stores an account_id, and account stores an 
>account_type id, I could have picked customer to be the main level 
>table, and just references out from there:

Mat:

Main level table?

I think that's one of the problems. There is no main level table -- 
there are just tables. It should not make any difference if you are 
addressing customers, accounts, account_types, emails, or whatever. 
They are nothing more than data and each has there own relationships.

Also, I think I see another problem. The account table holds the 
account_type, right?

If so, then your customer table should only contain the account_id, 
but NOT the account_type_id -- that's redundant.

To access what account-type the customer has means you pull the 
account_id from the customer table -- then look up that account 
(using the account_id ) in the account table -- then pull the 
account_type_id and then find the account-type via it's id 
(account_type_id) from the account type table. Understand.

customer: account_id
account: account_type_id
account_type: type

In any event, that's the way I would do it.

Cheers,

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list