Page 1 of 1

need help regarding my table structure

Posted: Sun Aug 23, 2009 8:51 pm
by greedyisg00d
I have a Employee table where its structure is EmployeeID, EmployeeName, Department and ClientsName. My problem is one employee can have many clients so my question is what is a good way on how to store multiple records to a single fields? In my case I plan to use a multiline textbox for inputting the name of the clients

Thanks

Re: need help regarding my table structure

Posted: Mon Aug 24, 2009 12:29 am
by matthijs
You'll have to create another table for the Clients and make a reference to the Employee. So that one Employee can have more clients. If you read a few tutorials about relational database design it will become clear what I mean.

Re: need help regarding my table structure

Posted: Mon Aug 24, 2009 8:17 am
by DaiLaughing
As matthijs said you need another table with perhaps just two fields - employeeID and client ID. Maybe also a third table which is the clients' records if it is possible that a client can have many emplyees looking after them. Either this for where clients only have one employee:

employee --> employeesClient

or this for where they can have many:

employeeInfo --> employeesClient <-- clientInfo

You do need to read up on it though as it is perhaps the main reason that DB people are fairly well paid.

Re: need help regarding my table structure

Posted: Mon Aug 24, 2009 8:51 am
by susrisha
just for information.. is this called many to many linking??

Re: need help regarding my table structure

Posted: Mon Aug 24, 2009 1:48 pm
by DaiLaughing
The second version is the way to get around the many-to-many problem, yes.