mysql - Modeling a directed graph with a special center node -
I am looking for opinions about a modeled model of a specific node.
Special node:
- It can not contain any edges.
- Can not Remove.
Current design:
Tables: Nodes, edges have two columns in the edges; The node refers to each record in the table.
Rather than storing the special node as the first record in the nodes table, I decided not to keep it completely recordable for its creation, from any database queries, in the table of edges, by tap In the context of node, by_node_id takes a special meaning in the column.
My motivation for using this design was that I would not be worried about defending the center node record by deletion / modification or being referenced in the to_node_id column of the edge table. It automatically prevents one edge from going to the same node I know that there are some drawbacks in this design, such as that is not able to make the _node_id and to_node_id the whole primary key, and possibly too much
I am currently leaning towards the center node and making a check for that node in relevant database methods. What is the best way to go about this design?
I see some arguments against using zero in this case.
- If the nodes contain actual data then you have hard-code data for the central node in the application.
- If the middle node can be changed, then the problem will be.
- The general meaning of zero is that there is no value or value is unknown. Because of this, it may be unwelcome to any other person who approaches the proposed design.
In other words, I would prefer to place a row in the database for the central node.
Comments
Post a Comment