- Learning Neo4j 3.x(Second Edition)
- Jér?me Baton Rik Van Bruggen
- 366字
- 2021-07-08 09:37:45
A graph model – a simple, high-fidelity model of reality
Let's take a quick look at how we can avoid the complexity mentioned previously in the graph world. In the following figure, you will find the graph model and relational model side by side:

On the right-hand side of the image, you will see the three tables in the relational model:
- A customers table with a number of customer records
- An Accounts table with a number of accounts of these customers
- A typical join table that links customers to accounts
What is important here is the implication of this construction--every single time we want to find the accounts of a customer, we need to perform the following:
- Look up the customer by their key in the customer table.
- Join the customer using this key to their accounts.
- Look up the customer's accounts in the accounts table using the account
keys that we found in the previous step.
Compare this with the left-hand side of the figure and you will see that the model is
much simpler. We find the following elements:
- A node for the customer
- Three nodes for the accounts
- Three relationships linking the accounts to the customer
Finding the accounts of the customer is as simple as performing the following:
- Finding the customer through an index lookup on the key that we specify
in advance - Traversing out from this customer node using the owns relationship to the accounts that we need
In the preceding example, we are performing only a single join operation over two tables. This operation will become exponentially more expensive in a relational database management system as the number of join operations increases and becomes logarithmically more expensive as the datasets involved in the join operation become larger and larger. Calculating the Cartesian product of two sets (which is what relational databases need to do in order to perform the join) becomes more and more computationally complex as the tables grow larger.
We hope to have given you some initial pointers with regard to graph modeling compared to relational modeling, and we will now proceed to discuss some pitfalls and best practices.
- 深入淺出Spring Boot 2.x
- Python GUI Programming Cookbook
- Learning Python Design Patterns(Second Edition)
- OpenShift在企業中的實踐:PaaS DevOps微服務(第2版)
- PLC編程與調試技術(松下系列)
- Keras深度學習實戰
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- JavaScript應用開發實踐指南
- Getting Started with Nano Server
- PHP與MySQL權威指南
- Node.js區塊鏈開發
- Modernizing Legacy Applications in PHP
- Java服務端研發知識圖譜
- 亮劍Java Web項目開發案例導航
- 跟著迪哥學Python數據分析與機器學習實戰