[eluser]jedd[/eluser]
[quote author="mdcode" date="1239103573"][quote author="kgill" date="1239102879"]I know you prefer the idea of short column names but the best solution is to use more descriptive column names in your tables to start with. E.g. cust_id, cust_name, cust_age, etc.[/quote]
...
Thanks for the input kgill, I summised that the second reference to "id" was overwriting the first in the set of results. Unfortunately, when I started pasting code here, and people saw that I had id columns and the like set as 'projectid' and 'customerid', I was advised early on to change them to simplify matters... so Idid and spent almost 2 hours reworking my entire db schema. I'm not sure how far to go changing it again...[/quote]
Don't go changing, to coin a phrase.
"A", as distinct from "the best",
solution is to change all your columns to reflect your table name, and then just in case you ever access two databases, you can further prefix the column names with the database name too ... so you will end up with:
Code:
customerdb_customer_id
customerdb_customer_age
customerdb_customer_address
customerdb_project_id
customerdb_project_name
Far more descriptive, of course, and will save you having to type 'AS cust_id' ever again .. and that's a HUGE saving. Sure, you get to type the word 'customer' 8 times as often, and the
meaning of your column names is now obscured amongst a lot of redundant noise, and if you ever make a subtle change to your schema you're up for a huge number of changes to all your column names ...
</sarcasm>
Context. A wonderful thing. You, and everyone else, should use it. In the same we way do not need to have the string 'controller' in all our controllers'
filenames - because they live in the
controller sub-directory - we can also live with uniquely identifying a column by the table that it is in.
That's precisely what the dot is for - to provide context.
customer.id is very readable and meaningful, and if you're only working in the customer table then the it's equally obvious and readable to rely on the context, and refer to just
id and
name and so on.