Database design - How can I have a foreign key of the primary key in the same table?

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-05-17T20:32:02Z Indexed on 2010/05/17 20:40 UTC
Read the original article Hit count: 273

Filed under:
|

My database has to store all the available departments in my company.

Some departments are sub-departments on another existing department. I've decided to solve this like this:

Departments
ID Description HeadOfDepartment ParentDepartment

ParentDepartment can be null, indicating it is a root department. If it has a parent I'll act accordingly, my question is how can I code this in Microsoft SQL?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2008