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


In my database, all my available departments are deposited in my company.

Some departments are sub-departments On another existing department, I have decided to resolve it in such a way:

  Department ID Description headOf Department Parent Department  

The parent department may be blank, indicating that this is a root department. If he has a parent, then I will work accordingly, my question is how can I code it in Microsoft SQL? Create pre-> Subscribed Departments (ID integer primary key, details varchar (255), headoff department code (255), parent department integer reference department (ID));


Comments