R
Ray
Hi,
I am wondering about proper or accepted practise for ID'ing records in a relational database.
My question is this...
If I have a table with a unique feature should I still use an ID column?
Example 1: (Note: SSN = Social Security Number - assumed unique to every person)
My database has a table called Employees, it has fields called "id" "fname" "lname" "SSN" - do I need the "id" field or will the "SSN" field do for ID'ing the record?
Example 2:
My database has a table called Cars, it has fields called "id" "make" "model" "registration" - do I need the "id" field or will the "registration" field do for ID'ing the record?
Now is it sensible to refer to the two tables in a master table like...
Example 3:
My database has a table called CarLog, it has fields called "id" "employee_SSN" "car_registration" "date"
And again do I need the "id" field or should I index off the date+SSN+registration?
I am thinking that in these circumstances can I delete the ID field each time to make the database smaller? In a lot of cases I can find uniqueness in the record without an ID field, is this what I should be looking to do each time?
Any comments appreciated.
Ray,
Dublin, Ireland.
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com
I am wondering about proper or accepted practise for ID'ing records in a relational database.
My question is this...
If I have a table with a unique feature should I still use an ID column?
Example 1: (Note: SSN = Social Security Number - assumed unique to every person)
My database has a table called Employees, it has fields called "id" "fname" "lname" "SSN" - do I need the "id" field or will the "SSN" field do for ID'ing the record?
Example 2:
My database has a table called Cars, it has fields called "id" "make" "model" "registration" - do I need the "id" field or will the "registration" field do for ID'ing the record?
Now is it sensible to refer to the two tables in a master table like...
Example 3:
My database has a table called CarLog, it has fields called "id" "employee_SSN" "car_registration" "date"
And again do I need the "id" field or should I index off the date+SSN+registration?
I am thinking that in these circumstances can I delete the ID field each time to make the database smaller? In a lot of cases I can find uniqueness in the record without an ID field, is this what I should be looking to do each time?
Any comments appreciated.
Ray,
Dublin, Ireland.
--
---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"
Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com