How to model a graph database

How to convert/model a relational data model into a graph data model?

We converted each table into a node and the columns into properties , and we converted the foreign keys and associated tables into edges. But the way we modeled (that is simple tables to nodes and foreign keys to edges do not work out very well to satisfy the query requirements.

I appreciate any suggestion on how to create graph data model

What is your query pattern that is not working out well?

I am still trying to convert the SQL queries into cypher. The SQL query uses windowing functions LAG and LEAD , COALESCE , aggregate functions, WITH clause and create intermediate tables.

The SQL query is written against data mart that has dimension tables and denormalized tables. The query calculate Simplified Acute Physiology Score II (SAPS II). The score is a measure of patient severity of illness. and it is calculated on the first day of each ICU patients' stay.

It is very long SQL query that I am trying to convert into Cypher and I posted this question to get suggestions on how to improve the graph data model before I start converting the query

It looks like you needs are analytical. I don't think Neo4j is going to provide the capabilities you get from a OLAP database. Is there a reason you are migrating to a graph database?

1 Like

Thanks Gary!

We are trying to show the power of graph database for health record data but I believe you are correct. it is not the best use case for graph.

Can we convert a dimensional model into graph data model? and Can Neo4j work as OLAP database? or Neo4j is only transactional database?

Converting a dimensional model into a graph database as is, like you have done, does not work well. We tried that early on in our graph journey and it also failed miserably. We now have a more normalized model that is for the questions we want to ask and it is actually working better than our dimensional model in the relational database. By designing your model for your questions (and not just any question like a dimensional model is for) you may find that your cyphers become simpler and perform better. Without more information on you questions you are trying to ask of your graph database, it is hard to help with model design.

1 Like