At 9:09 PM -0400 9/12/09, Matt Juszczak wrote:
For instance:
CREATE TABLE `account` (
-snip-
CREATE TABLE `account_type` (
-snip-
CREATE TABLE `customer` (
-snip-
As you can see, each customer as an account_id. But each account
also has type_id. I chose to do this like I did above, but why
didn't I call the tables:
customer
customer_account
customer_account_type
After all, that would have worked the same way, right?
No.
I see what you are saying, but "customer" is as different as
"account" is to "account_type". They are all different things. Why
confuse the matter by adding a customer prefix? There is no need.
Plus, if you're going to be consistent with that "mistake", then your
naming should be:
customer_customer
customer_account
customer_account_type
Do you see what I mean? That practice doesn't provide any clarity --
it only confuses things.
One additional consideration, which was discussed last week, was not
entitling the index of all tables as "id", but rather adding the
table name to the id, such as:
customer_id
account_id
account_type_id
That makes sense to me because when you're dealing with a bunch of
tables, a variable named "id" might be used incorrectly OR
overwritten.
For example, using:
SELECT * FROM customer WHERE customer_id = '$customer_id'
is just as easy to read as:
SELECT * FROM customer WHERE id = '$id'
But later in the code, after reading many different tables, what
table does "$id" relate to? It's not clear is it? But there is no
confusion with $customer_id is there?
HTH's
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/show_participation.php