RE: Naming Conventions: Table and Columns
Posted in 2000
Topics: Storage & Space Management, SQL Development & Query Writing
Yeah
It's called lazy.
I personally feel that ...
SELECT employee.emp_fname,
employee.emp_lname,
department.dept_division,
employee_timelog.emp_hours
FROM employee, department, employee_timelog
WHERE employee.emp_id = employee_timelog.emp_id
AND department.dept_id = employee_timelog.dept_id
... is unambiguous - and to some extent - self commenting.
If I recall correctly, SQL-92 has a concept of natural joins, where
something like ...
SELECT employee.emp_fname,
employee.emp_lname,
department.dept_division,
employee_timelog.emp_hours
JOINING employee, department, employee_timelog
... would return the same result - The join is on fields with the same name
Have a look at SQL-92
-----Original Message-----
From: Manoj A Menon [mailto:mmenon@apis.dhl.com]
Sent: 22 November 2000 11:12
To: informix-list@iiug.org
Subject: Naming Conventions: Table and Columns
All,
Let me explain what exactly I am after:
"The Table and Column Naming Guidelines/Recommendations"
I am looking for some table and column naming guidelines for Informix
tables - there are some well-known "standards" which say that "use the
same column name for the same purpose" -
[deleted]
Assume, we have
CREATE TABLE employee (emp_id int, emp_fname char (64), emp_lname (64) ) ;
CREATE TABLE department (dept_id char (6), dept_division char (6) ) ;
CREATE TABLE employee_timelog
( emp_id, dept_id, emp_hours number) ;
[deleted]
In article <8vgpm5$775$1@news.xmission.com>, Robert Stuart
<Robert.Stuart@nfer-nelson.co.uk> writes
>
>Yeah
>
>It's called lazy.
>
>
>I personally feel that ...
>
> SELECT employee.emp_fname,
> employee.emp_lname,
> department.dept_division,
> employee_timelog.emp_hours>
> FROM employee, department, employee_timelog
>
> WHERE employee.emp_id = employee_timelog.emp_id
> AND department.dept_id = employee_timelog.dept_id
>
>... is unambiguous - and to some extent - self commenting.
I use a different prefix for column names in each table except for
foreign keys (such as employee_timelog.emp_id in the above example), so
I would use employee_timelog.empl_hours, not emp_hours. After all
emp_hours is certainly not a foreign key!
It's also worth making sure all table names are either singular or
plural - it's confusing to have a system where there's a mixture. Here
speaks experience....
Quite a few packages which access database schemes and the 'do things'
with them require that joined columns share the identical name.
>
>
>
>If I recall correctly, SQL-92 has a concept of natural joins, where
>something like ...
>
> SELECT employee.emp_fname,
> employee.emp_lname,
> department.dept_division,
> employee_timelog.emp_hours
> JOINING employee, department, employee_timelog>
> ... would return the same result - The join is on fields with the same name
>
>
>Have a look at SQL-92
Ah! Confirming my comments above, though I was really thinking about PC
packages drawing pretty pictures of the schema.
>
>
>-----Original Message-----
>From: Manoj A Menon [mailto:mmenon@apis.dhl.com]
>Sent: 22 November 2000 11:12
>To: informix-list@iiug.org
>Subject: Naming Conventions: Table and Columns
>
>
>All,
>
>Let me explain what exactly I am after:
>"The Table and Column Naming Guidelines/Recommendations"
>
>I am looking for some table and column naming guidelines for Informix
>tables - there are some well-known "standards" which say that "use the
>same column name for the same purpose" -
>
>[deleted]
>
>Assume, we have
>
>CREATE TABLE employee (>emp_id int, emp_fname char (64), emp_lname (64) ) ;
>
>CREATE TABLE department (>dept_id char (6), dept_division char (6) ) ;
>
>CREATE TABLE employee_timelog
>( emp_id, dept_id, emp_hours number) ;>
>
>[deleted]
Surfer! Send email to: surfer at
nevis-view dot
demon dot co dot uk
"I can resist anything but temptation" - Oscar Wild ;-)