How to insert a tree into a database using the ER model

Hey today I was at an interview where they gave us a tree with an unknown structure (maybe not binary), and I was asked to insert it into the database in a certain order, where I could return the dB to the tree and show that I did it uses the model ER, each node in the tree has two data items data1 and data2

can someone answer or give me a hint how this is done?

EDIT: what I wrote is that every child has a father, we must add a connection between the nodes of the father and son because the son has one father, the son has an arrow one to one to his father - I gave each of these, a pointer, and each sun had a pointer to his father, and what does it have to do with the ER model? I don’t know, that’s why I asked him here.

+3
source share
2 answers

One thing you can do is to mark en the whole branch with an index (say 1,2,3 ..), and now the whole branch with a specific index can be taken as a record. Browse through the whole tree and try to find some kind of relationship between the data and assign some attribute name to each node at each level of this tree. Now, once you have done this, you can highlight what these attributes are .. and create an entity that can represent these attributes (or properties). Now that you decide that you have decided to create an entity and attributes in ERD (entity relationship diagram)

if you have gone through a network database design model, then you can get some more tips

, ,

0

?

, " ER" , . :

  • (RM)
  • (ERD)
    ;
    , " ER" .

" ER" , . , ( ) ER ().

, , - , , .

"" "" ER Diagram , . Thvia the FK e ; -, . "/" , B-Trees ( " " ) Relational ( , "" )

/ , , , .

0

Source: https://habr.com/ru/post/1771205/


All Articles