Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM: Advanced Databases for Beginners

date posted 6th September 2006 16:47

> I agree with the title and author tables, (book_title/ book_author, bad bad
> bad) but normally I use a specific id field - ie: 'book_id' or maybe 'bid'
> so if a select statement requires id's from multiple tables that are easier
> to distinguish between.
>
> What's on the downside of naming an id field in this way?

I would have thought the best goal to aim for would be consistency,
and to that end if you've named all of your primary keys "id" rather
than by some arbitrary contraction such as "bid" then it means you can
just get on with the idea of writing the SQL rather than having to
refer back to your table definition every 5 seconds so you can work
out what you called the field. You can easily distinguish between
id's by use of table aliases, which you probably should be using
anyway.

The idea of establishing a coding convention is for readibility and
consequently ease of use - I guess it's whatever works best for you,
however I'd agree that NOT prefixing every field name with the name of
the table is a good move. One place I worked at insisted that each
field name was prefixed by a character to indicate the datatype (e.g.
v_first_name, i_id), however the convention used for database fields
was different to the convention they used for within the scripting
code.

I forget what point I was trying to make there, but it's nice to
participate in a discussion, isn't it ?? :)

Jason



Messages by Day
September 30th 2006
September 29th 2006
September 28th 2006
September 27th 2006
September 26th 2006
September 25th 2006
September 24th 2006
September 23rd 2006
September 22nd 2006
September 21st 2006
September 20th 2006
September 19th 2006
September 18th 2006
September 17th 2006
September 16th 2006
September 15th 2006
September 14th 2006
September 13th 2006
September 12th 2006
September 11th 2006
September 10th 2006
September 9th 2006
September 8th 2006
September 7th 2006
September 6th 2006
September 5th 2006
September 4th 2006
September 3rd 2006
September 2nd 2006
September 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000