samedi 2 janvier 2016

How to model: Team <-(1) --- (N)-> Employees, with a twist; Better Pattern?

I have to model and create in a SQL Server database a simple relationship...

A Team can have zero or more Employees assigned to it; An Employee can only be assigned to a single team. Simple enough... Here is the twist that I am struggling with...

The Team has a TeamLeader, who is an Employee. A TeamLeader can be assigned to a single Team. So, I added the TeamLeaderId long to the Team and gave TeamLeaderId a unique index. I created a foreign key relationship between the TeamLeaderId in Team to and EmployeeId in Employees.

Is this the best model for this situation, or is there a better pattern?

Thank you for your help and guidance,

Mike

Aucun commentaire:

Enregistrer un commentaire