I'm making a database diagram and I'm facing the situation explained below.
Business rules:
- A device could have multiple connections with others devices (It's a graph).
- A device could be a server, a switch or store unit (for the moment, could raise).
- A device belong a one system.
So, I need it design this multiple reflexive relationship between devices. I believe that I achieved it with the next model, but I'm not sure if it's the best solution.
Reality and Problem:
A device could have multiple devices (links) and belong to multiple devices.
So my diagram is as follows:
Diagram Explanation:
The Device concept was created because the information of all devices is similar relative. So the properties that differ could be optional. I believe that the solution for the multiple reflexive relationship is to create other concept that has a copy of first concept ID (device) to apply the partition and get the link between multiple devices. This copy is generated when some inserts a device (with a trigger or with simple other insert, in chain from logic layer). The purpose of the ID copy is to allow creating relationships between all devices.
Any idea for this case? Thanks.
Best Answer
I'll answer for an RDBMS, like PostgreSQL. Here we use a many-to-many table.
Now I think you want something like this.
That models this schema, assuming simply that non-servers can only be connected to servers.