design-first/system-designer

Graph Database

davidmw opened this issue · 9 comments

I've been hunting for a design solution to help with modelling graph databases. There really isn't much available in the space beyond illustration / charting tools.

I haven't found a good way to bend system-designer to that task but it may not be much of a stretch.

Visually on the final output, links need labels and properties visible. Perhaps this is a special link type called 'edge' or 'relationship.' I need multiple edge types (often grouped in like-type collections) defined ('is child of', 'contains part', etc). Edges have ids, custom properties, direction / bi-directional, and connect to two nodes.

Nodes need to support an array of edges in and an array out. I won't keep rambling - but do really enjoy system-designer!

Thanks for your suggestions !

In fact, for the moment, the generated graph is quite simple in order to edit then after if you need a more complex graph. Example:

  • you export the graph in a Graphviz format,
  • you edit the file and extend it following the specification,
  • you can show the edited diagram in System Designer (by drag/drop the file in the Graph viewer) or with another tool.

But I can add helpers to do what you want without the need to edit the Graph. To do so:

  • I will use the description property of the link / collection to add as label of the link and
  • I will add a kind property to change the way the link is shown. Values can be: aggregation, composition and dependency. It will change the shape of the arrow with the appropriate link.

Example:

  "author": {
    "description": "author of the book",
    "kind": "aggregation",
    "type": "Author",
    "readOnly": false,
    "mandatory": false,
    "default": ""
  }

Remember also that systems created with System Designer are NoSQL-oriented because all components are stored in memory in a NoSQL database at runtime. So maybe some concepts are still missing for doing a complete Graph database design. I have to investigate.

  • add kind property to links and collections.
  • add an example system that contains by default Nodes and Relationships schemas and models to create Graph Databases.
  • add an option to generate a Graph diagram instead of a Class diagram.
  • add a documentation that explains how to make query on Nodes and Relationships.

Just - Wow! Looking forward to the update as the plan looks great!

The implementation of the task is done. I have to create a doc to explain how to use it in System Designer, but basically:

  • you need to import a system from the example that contains Nodes and Relationships models,
  • then you need to create models that extend these 2 models and
  • Relationships models have incoming and outgoing properties that you need fill when creating relationships components.

That's all. You will see then your system in 3 different diagrams: Class, Component and Graph diagrams to have a complete overview of your system.

To request your graph system you will need to query the NoSQL repository like that:

// get all relationships of class MyRelation that have a specific component 
this.require('db').collections().MyRelation.find({
  'incoming': {
    '$eq': 'id_of_the_component'
  }
});

component-diagram

graph-diagram

The OSX app update was downloaded from the AppStore. I imported the graph example and see Node & Relationship schemas.

App doesn't let me directly "create models that extend these 2 models" so I need to create schemas. When I open the Node and Relationship schemas / models I don't see the new 'kind' property. Perhaps no default was intended.

I created a new schema for my first node collection type of 'account' and 'inherit' the default Node schema, then do the same for my first relationship. Then create components with my new model, link the relationship up - the diagrams are not what I expected from your examples above.

Maybe I do need documentation or a video example.

I have just finished the documentation that you can find here: https://designfirst.io/systemdesigner/documentation/docs/create-a-graph-system.html.

For incoming and outgoing links there is no kind property because because these links will be displayed the same in the Components diagram. I can make these 2 links use the kind property but do you have an example where we need to change the look of these links? Just to understand better the need.

kind property will work for all other link / collection. And can have for values: normal, dependency, aggregation or composition.

If you have any feedback on the documentation I have created, do not hesitate.

I don't have current plans for kind and was just commenting that I don't see it in use. If there is a documented example I've missed it in my time crunch.

Forgetting to override incoming and outgoing links in a relationship model is perhaps always an error. So maybe they should be added to the model by default? Otherwise I get something like:

screen shot 2018-09-05 at 12 11 29 am

Auto generated IDs would better match my implementation if created in a GUID format.

Linking up components using default IDs is a bit painful, requiring use of the tabbed interface to find the correct object. The relationship model already defines which models are to be linked so maybe when the edge component is created you should show a list of available components and a summary of properties when setting up both inbound and outbound.

I'd like a option to not sort properties - maintain my property order in schema, model, and diagrams.

LInk and component appearance on the Component Diagram is the same for nodes and relationships. I won't suggest that relationship be a diamond shape but maybe use a dashed or light border?

some comment about the actual behavior:

  • by default if you do not override incoming and outgoing links, the created relationship will be on all nodes. That is why you have contains on all nodes.
  • there is autocomplete on components ID, but you need to type the first letter of the ID.

autocomplete

I plan to add:

  • ID in GUID format.
  • an option to avoid automatically sort of the properties of the schema/model/component.
  • make relationships more noticeable on Components diagram.

Many improvements have been made on System Designer v3.1.2.
I close this issue as the task as been completed. If you find issues / needs some improvements, please create another tasks.