Rodney H. wrote:Is it silly to use the naming convention as is, but to use ALIAS properties/column names in my queries??
Waste of time and lots of extra typing.
Always code on the basis that someone else will have to work with it one day. By naming primary key id columns for the table, anyone can see immediately which table is refered to. By also naming related foreign keys the same then it is obvious what the relationship is without having to examine the db schema - which probably won't exist in any case.
table Main
main_id
type_id
cat_id
branch_id
etc
etc
table Types
type_id
etc
table Cats
cat_id
etc
table Branches
branch_id
etc
See, the whole thing becomes obvious.
As to the second point: it comes from my background in client/server apps.
Rather than create a query naming specific fields, one just does SELECT * and passes all the data to the 'client'. It makes it easier in the long run when you add columns to the tables (which you will) and/or the client GUI needs changing, you don't have to go back and change the query as well.
Using 'USING (cat_id)' in the JOIN clause means that you don't get the cat_id column returned twice, which you would if you used 'ON (main.cat_id=cats.id)' or even 'ON(main.cat_id=cats.cat_id)'. Less data to send and less confusion as to which id column is which.