I’ve got a bunch of facts about people and organizations, and I want to define relationships between those people and organizations (kinda classic Prolog stuff, really), and I’m trying to figure out if this is best done with its own entity(-ies) or if I’m missing something cleaner. I’ve ended up with a schema that’s something like:
[fact-id][Entity-A][Relationship][Entity-B][dependency-ids]
My facts are things like [Fred][Supervises][Bill], [Acme][Employs][Fred], [Acme][Employs][Bill], [Funco][Employs][Bill], etc.
The facts can be independent of each other but need to be able express when the facts are connected. Maybe Fred is Bill’s supervisor at Acme, but Bill is Fred’s supervisor at Funco, or maybe Bill supervises Fred at both places. Here’s a potential set of facts:
[1][Acme][Employs][Fred]
[2][Acme][Employs][Bill]
[3][Fred][Supervises][Bill][1 2]
[4][Funco][Employs][Fred]
[5][Funco][Employs][Bill]
[6][Fred][Supervises][Bill][4 5]
[7][Funco][Employs][Joe]
[8][Joe][Supervises][Fred][7 4 6]
If I want a list of Bill’s supervisors, I should see Fred. If Funco fires Fred, Fred still supervises Bill but only at Acme, and Joe no longer supervises Fred, because he’s fired. Also, if just Bill gets fired, Joe no longer supervises Fred (let’s say because Fred only supervises supervisors).
Have I over-complicated this? Originally, I was just thinking:
[Entity-A][Relationship][Entity-B]
But I feel like I have to have the dependency list because A and B can swap their relationship under different contexts.