Relational model of an organizational structure, SQL SERVER

0

if someone can help me ..

I am creating a database for an organizational structure of a company that has different levels, that is I have a main node from which more children hang and so on 6 levels. It's saying something like that ..

The organizational structure would be something like the left part of the image, and the right part represents the tables of how I am trying to create the structure

My question is whether the correct way is to create different tables and put them together by making primary and foreign keys. In addition, each table has the same attributes, code, name, and description, so I wonder if I would have to do a specialization, but if I did a specialization the children inherit the attributes and then the children would be related? I do not know if you can make the children in a specialization depend on each other, to represent the levels of the structure.

I have decided to start by creating the e-r diagram and when hanging from one another, are they not depending on the previous one? That is, should not they be weak entities? But if they were weak entities, at the third level we would have a weak entity of a weak entity and I think that this can not be done.

I do not know if I expressed myself well, if someone can give me a hand and give me an idea of how I would have to do the organizational database, I would appreciate it.

Thank you!

    
asked by Paulo Rodriguez 10.04.2018 в 15:05
source

1 answer

0

I would say that the tables are one, with a reference to themselves. Then a field that is the type DO, GC, VO, etc .. That column can be a foreign key perfectly to another table that is called type but it is yours because it does not necessarily have to be like that.

It would be something like:

Node

id_nodo | name | code | id_nodo (if it is not null indicates it is a daughter) | type

-------------------------- the other alternative

Node

id_nodo | name | code | id_nodo | id_type

Type

id | name_type < - GC, VO, etc ...

Greetings!

    
answered by 10.04.2018 / 15:30
source