在这个数据库中,有时员工只在一个司法管辖区,有时不止一个。例如,Bob 的司法管辖区将是北美、南美和非洲。而简斯将只是北美。但是,每个员工都会有一个部门。
由于某些员工只会分配一个管辖区,而其他员工可能会分配更多管辖区,这是实施管辖区的最佳方式吗?或者有没有更有效的方法?
我将使用连接语句并按部门选择我的查询。
employees
-----------------
userID (primary key)
deptID (foreign key and NOT NULL references departments)
firstName
lastName
jurisdiction1 (foreign key references jurisdictions)
jurisdiction2 (foreign key references jurisdictions)
jurisdiction3 (foreign key references jurisdictions)
jurisdiction4 (foreign key references jurisdictions)
jurisdiction5 (foreign key references jurisdictions)
jurisdiction6 (foreign key references jurisdictions)
jurisdiction7 (foreign key references jurisdictions)
jurisdictions
-------------------
jurID primary key
jurisdictionName
departments
--------------------
deptID primary key
departmentName