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
need help regarding my table structure
Moderator: General Moderators
-
greedyisg00d
- Forum Commoner
- Posts: 42
- Joined: Thu Feb 12, 2009 2:48 am
Re: need help regarding my table structure
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.
-
DaiLaughing
- Forum Commoner
- Posts: 76
- Joined: Thu Jul 16, 2009 8:03 am
Re: need help regarding my table structure
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.
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
just for information.. is this called many to many linking??
-
DaiLaughing
- Forum Commoner
- Posts: 76
- Joined: Thu Jul 16, 2009 8:03 am
Re: need help regarding my table structure
The second version is the way to get around the many-to-many problem, yes.