473,216 Members | 1,288 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Is "name" a keyword?

It's blue in SQL Studio but I can't find it in SQL Books on-line. I
wanted to use it as a field name but don't like using [].

Is it reserved?

Dec 27 '05 #1
6 17108
It is not a keyword in Standard SQL, but it is too vague to be a column
or other data element name by itself

It is a modifier -- think about what it. Name?? Name of what?
Employee? Pet? Product? etc.

Also a field is a totally different concept from a column!.

Dec 27 '05 #2
Cecil wrote:
It's blue in SQL Studio but I can't find it in SQL Books on-line. I
wanted to use it as a field name but don't like using [].

Is it reserved?


It's reserved for the inexperienced who won't bother to come up with a
more useful and informative name. The rest of us know better because
we've had too many bad experiences trying to make sense of other
people's designs with fatuous names like "ID", "NAME", "DATE" or (I kid
you not) "DATA".

--
David Portas
SQL Server MVP
--

Dec 27 '05 #3
OK, can you help me to understand why ID and name are poor field
choices. I am asuming it has to do w/ ambiguity. I always qualify
fields w/ their table names for precisely this reason, so I always
concidered something like Category.categoryID to be very redundant.

I prefer Category.ID and Category.name. The only time I would write
CategoryID is if it was a foreign key linking to the "ID" field in the
Category table.

If you believe this to be poor practice, would you please explain why?
Thanks.

Dec 28 '05 #4
Cecil wrote:
OK, can you help me to understand why ID and name are poor field
choices. I am asuming it has to do w/ ambiguity. I always qualify
fields w/ their table names for precisely this reason, so I always
concidered something like Category.categoryID to be very redundant.

I prefer Category.ID and Category.name. The only time I would write
CategoryID is if it was a foreign key linking to the "ID" field in the
Category table.

If you believe this to be poor practice, would you please explain why?
Thanks.


Naming conventions are supposed to aid understanding, verification,
interchange, and ongoing maintenance of code by others. Generally
accepted standards and conventions therefore ought to be more important
than personal preferences. Quote: "Any fool can write code that a
computer can understand. Good programmers write code that humans can
understand." (Martin Fowler). The same applies to your data model.
There is in fact an international standard for naming data elements:
http://metadata-standards.org/

One principle that's very widely used and that works well is that every
single data element should have a unique name in your database schema.
That means that foreign keys usually have the same name as the column
that they reference and that most column names won't appear in more
than one table except where they are keys or part of compound keys.

The advantages of using unique names are many:

- When maintaining schema and code you can easily search for column
name references in your code because each column has a unique name.
Your idea of qualifying each with the table name won't work because in
correlations and multiple joins to the same table you may be forced to
use aliases rather than table names. That means you can never reliably
search for a particular column. You'll have to manually check for each
occurence of "NAME" to see if it's the right one.

- Types and constraints can be defined and checked by column name
throughout the database. This is ideally suited to systematic auditing
of the schema, something which ought to be part of any implementation.

- Data dictionaries can be smaller and simpler to use by referencing
each element name rather than each table and name.

- Your code will be more readable if you use short aliases but that
only helps if you use concise and meaningful column names.

- Data interchange with XML for example is also made easier if you use
unique names for data elements.

- You'll be much less likely to clash with present and future reserved
keywords because most keywords are simple nouns or verbs whereas the
column names that are likely to conflict with them are usually
compounds.

--
David Portas
SQL Server MVP
--

Dec 28 '05 #5
David,

Thank you for your thoughtful reply. I will consider adopting your
recommendations.

Dec 28 '05 #6
I agree with 'DATE' and 'DATA' but ID and NAME, it depends on your style.

Its good practice to alias table's on the FROM clause and to specify the
alias when referencing those columns - it helps maintanence by knowing
clearly where columns are referenced from.

create table Logon (
id int not null....

The above declaration for instance, in a SQL statement you would write...

select logon_id = l.id
from Logon l

The table (set) is a container in the same way an object (table) is a
container, the object just contains properties (columns) though rather than
any methods.

My two cents.

Tony.

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"David Portas" <RE****************************@acm.org> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Cecil wrote:
It's blue in SQL Studio but I can't find it in SQL Books on-line. I
wanted to use it as a field name but don't like using [].

Is it reserved?


It's reserved for the inexperienced who won't bother to come up with a
more useful and informative name. The rest of us know better because
we've had too many bad experiences trying to make sense of other
people's designs with fatuous names like "ID", "NAME", "DATE" or (I kid
you not) "DATA".

--
David Portas
SQL Server MVP
--

Dec 28 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Todd Gardner | last post by:
Pardon my extremely ignorant newbie questions. Where can I go to find more information about the "self" argument? Is there something special about the word "self" or did Mr. Guido van Rossum...
3
by: Sean Berry | last post by:
How do I rectify this? ------vars.py------ #!/usr/local/bin/python def setUserid(value): userid = value def getUserid():
2
by: Liang | last post by:
Hi, I use "defined $r_libs->{$name}" to check first if a key exists in a hash table. But Perl gives a warning WHENEVER the key exists: "Use of uninitialized value". Would u please help to...
2
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? ...
3
by: Alfred E Neuman | last post by:
I've read that... AClass ac = AClass( "name", 23 ); is less efficient than... AClass ac( "name", 23 ); because the first has to create a temporary object which is then assigned to ac. ...
3
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their...
1
by: A.M-SG | last post by:
Hi, I am trying to simplify my app.config file. Can I have a section handler in a separated file? I am looking for something like this: <section name=".." type=".." file="..."> but it...
1
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form...
1
by: mato81 | last post by:
Hi all! I am a newbie to WSDL. I have a questions which has been driving me crazy... If I would have a WSDL with a types element somewhat like below, what is the point of the third last row...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.