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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Design a simple login database question...

Author  Topic 

vyphan
Starting Member

1 Post

Posted - 2010-10-19 : 12:58:15
Hi,
I got an database design in SQL Server 2008.
I design a simple login database with 4 table:
Roles
Users
Employees
Clients
Users include Client and Employee. It means both Client and Employee can login into system.

I mean UserId can be EmployeeId or ClientId. But how to make relation between Users table and Employees and Clients.
Case 1:

I just implemented this and when I insert row to Users table, SQL Server appears an error message like this

If UserId is a foreign key references to EmployeeId and ClientId, EmployeeId and ClientId must be the same. It's illogical.
Case 2:

Employees and Clients are important tables. If I don't need login function, I will delete Users table. If I set relation like this, when I delete Users table, it means Clients and Employees tables will be deleted too. It's not data integrity.

Please help me make relation between these tables.
Thank you so much.
   

- Advertisement -