addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [TriPUG] [mysql-144] Tripug: PHP Best Practices: SQL column prefixing

From: Brian M.
Sent on: Thursday, August 19, 2010 9:29 AM
On Wed, Aug 18, 2010 at 10:32:49PM -0400, Simon wrote:
>  >>> Database field names should not be prefixed with "field_" or "fld_" 
> or, really, anything.
> I've used column (field) prefixing to avoid ambiguity when tables with 
> some common column names are joined and the data is being retrieved 
> using the column names (mysql_fetch_assoc()­, mysql_fetch_object()­, etc). 

With a slightly different twist on this conversation, many years ago, when I was working in the Oracle world, I was taught to add a suffix to each column name that identified the table that it lived in.  Therefore, in a table called users, there might be a column named seqno_u.  As well, in the case of foreign keys, the column name might become something like userid_u_co, for a column in the company table.


Brian


Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy