Skip to Content
Neo4j: The Definitive Guide
book

Neo4j: The Definitive Guide

by Luanne Misquitta, Christophe Willemsen
July 2025
Intermediate to advanced
410 pages
6h 21m
Japanese
O'Reilly Media, Inc.
Content preview from Neo4j: The Definitive Guide

第3章. モデルの決定を再検討する

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

グラフモデリングは直感的なプロセスであるが、ビジネスにおけるユースケースを明確に理解する必要がある。リレーショナルスキーマの設計とは異なり、柔軟性があり、固定規則がないため、最初は戸惑うかもしれないが、プロセスに慣れてくると、やりがいのある練習であることがわかるだろう。

第1章で作成したグラフを使って、この後のクエリを試してみよう。

依存関係

曲、アルバム、アーティスト、そしてそのジャンルを含むデータセットが与えられ、リレーショナルデータベース管理システム(RDBMS)用のスキーマを設計したいとしよう。あなたはおそらく、おなじみの正規化規則を適用し、似たような構造モデルに行き着くだろう。1を適用し、図3-1のような類似性のある構造モデル(テーブルとカラムの名前付けは異なるかもしれない)を作成することになるだろう。

図 3-1. RDBMSのスキーマ

これをグラフとしてモデル化するにはどうすればよいだろうか?熟練したグラフモデラーとしてのあなたの答えは、「依存関係だ!」であろう。本当か?そうだ。図3-2から図3-4は、3つのグラフモデルを示している。

図3-2. モデルAはジャンルをアーティストのプロパティとしてモデル化する。
図3-3. モデルBでは、ジャンルはノードで、アルバムはプロパティである。
図3-4. モデルCでは、TRACK_VERSION ノードとラベルとしてのジャンルがある。

データセットにエンティティを追加すれば、可能なモデルの数は増える。どのモデルも間違ってはいない。その適否はユースケースに依存する。だからこそ、ベテランのグラフモデラーとして次に言うことは、"グラフにどんな質問に答えてほしいのか?"なのだ。ユースケースによって、どのモデルがグラフに求める質問に答え、効率的なクエリを実行するのに最適化されるかが決まる。

ヒント

他のことと同様に、シンプルにすることを強く勧める。十分なモデルを作るが、それ以上は作らない。

グラフモデルはいつでもリファクタリングすることができる。グラフモデルは、ビジネスの変化に合わせて常に進化していかなければならない。リファクタリングが必要になるのは、主に以下のような場合である:

  • 新しい種類のデータ

  • 新しいユースケース

  • データ量が急増する

  • ビジネスドメインが進化または変化する

3-2から図3-4のモデルがすべて有効だとしたら、どれを選ぶべきか?どれが「正しい」のか?それはユースケースに依存する!今、あなたの主なユースケースは次のようなものだ: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Elasticsearch in Action, Second Edition

Elasticsearch in Action, Second Edition

Madhusudhan Konda
Fluent Python ―Pythonicな思考とコーディング手法

Fluent Python ―Pythonicな思考とコーディング手法

Luciano Ramalho, 豊沢 聡, 桑井 博之, 梶原 玲子

Publisher Resources

ISBN: 9798341664760