Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why do they refer to the table name in every fieldname?


May be it exists in their coding guidelines? Although tablename.tablename_columnname sounds repetitive and verbose, it might in some cases be of help when one deals with too many tables and too many keys with the same name across tables.


>May be it exists in their coding guidelines?

I think the question would be why would this exist in their coding guidelines.

>Although tablename.tablename_columnname sounds repetitive and verbose, it might in some cases be of help when one deals with too many tables and too many keys with the same name across tables.

tablename.tablename_columnname is not likely what's being done for their queries... in many RDBMS's, you can omit the "tablename." part if columnname is unique in the DB, so it will actually reduce repitition and verbosity, even if you hate typing "_" as much as I do.

It also makes dealing with "duplicate" names easier, because there will be no dupes: you won't have any columns or keys across tables that have the same name, because the prefix will differ, and in your queries and various etceras you won't ever have to think "which 'from' is this?"

With all of this, it also eliminates the need for (other, explicit) aliases, if you're doing it right.

Or at least that's the story: some people consider this equivalent to using Hungarian notation in Python ... I'm not one of those people, for the reasons above.


It can make many joins easier since you avoid field conflicts. This way you do not need to include any 'AS' statements in your SQL query.

After a query you can also easily identify which table the field came from.

That's my guess at least.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: