Will Tomlinson wrote:

>>This is the exact reason I gave it ago with singular table names. tblPeople,
>>with a PK of PersonID or PeopleID didn't sit too well, tblPersons didn't
>>seem right either.
>>    
>>
>
>
>When I was reading through this thread, I started asking myself who names a 
>table tblpeople anyway? lol! I know I have less experience than most on the 
>list, but I've never built a tblperson or tblpeople. What does tblperson 
>represent?
>
>tbldoctors
>tbllawyers
>tbladministrators
>tblemployees
>tblusers
>
>Where would I use tblperson and need to make it plural anyway? What does 
>tblperson represent? Wouldn't you use something more specific? 
>  
>
Nope.  You use something generic.
If you have tblDoctor, tblAdmin, tblLawyers, what happens when you have 
another type of job? Say nurses or barristers?  You'd have to create 
another table and a whole bunch more logic to handle them within your 
application.

If you use something more generic then you can add as many "jobs" as you 
like with only minor changes to your application logic to handle the 
additional types.

tblEmployee is ok as is tblUser, because these are both fairly generic, 
allowing you to add as many employees or users as you like and then 
apply a job title/description to an employee (director, secretary, 
doctor, nurse) and roles to users (user, administrator, moderator).

Below is an example of storing a person's details and being able to 
assign them to multiple "types".  If you only wanted to allow a person 
to have one "type" you would place "PersonTypeID" in tblPerson as a 
foreign key.

tblPerson
=======
PersonID
Name
Address
TelNo

lnkPerson2PersonType
===========
PersonID
PersonTypeID

tblPersonType
==========
PersonTypeID
Title
Description

tblPerson
----------
PersonID Name                   Address                       TelNo
1              Stephen Moretti   Newcastle Upon Tyne  0845 226 2896

tblPersonType
---------------
PersonID Title             Description
1               Director     Company Director
2               Developer  ColdFusion Developer

lnkPerson2PersonType
------------------------
PersonID   PersonTypeID
1               1
1               2

Now with tblPersonType, I can add as many types as are needed by the 
application and add more when I realise I've missed some.  I can be 
anything I want, doctor, nurse, evil genius..... just by adding the type 
to the table and linking the person to the new type.

PersonID Title             Description
3              Evil Genius  Austin Power's latest nemesis

lnkPerson2PersonType
------------------------
PersonID   PersonTypeID
1               3

I hope that makes sense.

Regards

Stephen
PS.  Please excuse the "evil genius" stuff....  Having one of those 
mornings..... :D


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:200661
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to