"Allen Browne" <(E-Mail Removed)> wrote in
news:#(E-Mail Removed):
> In your 3rd table, why have you used the combination of EmployeeID
> + ProjectID as primary key? Are you trying to insist that no
> employee can ever be involved in more than one project? Since the
> primary key must be unique, that will be the effect.
>
> For a many-to-many relation, you would normally have fields like
> this in the 3rd table:
> EmployeeProjectID AutoNumber primary key
> EmployeeID Number relates to Employee
> table ProjectID Number relates to
> Project table JoinDate Date/Time date
> this employee joined this
> proj.
> LeaveDate Date/Time date this emp. left
> this proj.
I don't understand your recommendation, Allen. A join table needs to
have the composite key on the foreign keys being joined, as the
original poster described. That is, unique composite key on
EmployeeID + ProjectID. That doesn't restrict the employee to a
single project, it just limits the join table to one record per
employee project. That makes sense, as what value would there be to
have the same project joined to the employee twice?
Now, if an employee can join and leave a project multiple times,
then it seems to me that belongs in a different table. If, on the
other hand, the employee joins and leaves the project only once,
then those attributes are part of the employee/project record.
The Autonumber surrogate key you've added serves no useful purpose
when the business rule is to allow only one instance of each project
per employee. but if you are linking a table of project dates to
this join record, then the surrogate key becomes very useful. In
that case, the surrogate Autonumber would be the PK, with a unique
composite key on the EmployeeID + ProjectID.
Do you disagree?
--
David W. Fenton
http://www.dfenton.com/
usenet at dfenton dot com
http://www.dfenton.com/DFA/