0

Is it possible to model a recursive relationship (such as seen in the photo) using the relational model? I find it hard to believe that the relation user would receive a foreign key from itself to signify the 1:n relationship it has with itself in the relationship "is_referred_by". An entity in an EER Diagram with a recursive relationship

Simon
  • 1
  • I'm not sure what you're asking. Why couldn't an entity refer to another entity of its own type? – Dave Newton Feb 10 '21 at 13:52
  • Don’t see why not. Going to ultimately depend on your database. Some might not allow foreign key constraints to their own key, so you’d have to add a check constraint (for example). But... nothing “wrong” with doing it that way. – Nicholas Rees Feb 10 '21 at 13:54
  • I think another way to think about answering your question is asking: “does it work” and “will the next person understand how it works”. Without knowing more details, I think I could both make it work the way you described and I would understand what you were doing if I came after you to maintain it and you had made it work that way. So... yes. It’s fine. – Nicholas Rees Feb 10 '21 at 13:56

0 Answers0