Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 quick database schema

Author  Topic 

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-04-08 : 23:28:36
if i have two tables Salesteam and Department.

Department has departmentname, departmentid

salesteam has SalesTeamID, SalesTeamEmployee, SalesTeamDepartment

departments can have lots of SalesTeamEmployees but each SalesTeamEmployees can only belong to one department

how do i set this up?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-08 : 23:32:43
Set what up? Are you asking us to write a query or design another table?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-04-08 : 23:44:30
i need to know how to limit the salesteam member to one departmnent only
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-09 : 00:21:55
One way to acheive this is using triggers.

In the Trigger code you can check using inserted table whether the salesteam employee is already assigned to any dept or not and take action accordingly.

Regards,
Pramod

I am here to learn from masters and help new bees in learning.
Go to Top of Page

tpiazza55
Posting Yak Master

162 Posts

Posted - 2010-04-09 : 00:24:49
can you do it with some kind of unique constraint
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-09 : 00:59:26
If i understand correctly then you have 3 tables together.
Department -> Holding department information
Employee -> Holding Employee information.
SalesTeam -> Holding combination of both.

If my understanding is correct then you can try creating an unique constraint for SalesTeam on SalesTeamEmployee

Regards,
Pramod

I am here to learn from masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -