Database Reference
In-Depth Information
• A
person
lives at
an
address
.
• An
underground station
is connected to
another
underground sta-
tion
on
an
underground line
.
• A
smartphone bundle
includes
a
smartphone
and a
call allowance
.
These patterns fit collections of facts:
•
Peter
lives at
The Gables
.
Mary
lives at
13 Acacia Avenue
.
•
Bank Station
is connected to
Moorgate Station
.
Bank Station
and
Moorgate Station
are both
on
the
Northern Line
.
• The
light usage bundle
includes
a
FictoPhone smartphone
, and
150 minutes per month of mobile-to-mobile calls
.
Once you have a consistent description of the data that will be stored in the database, you
can use this description to reason about the queries you'll put to that database in the future.
A common way of expressing such a description is through diagrams. By drawing frag-
mentsofgraphsthatrepresentcommonpatternsinyourdata,youcanvisualizeyourmodel
in an intuitive way. In the early stages of Neo4j data modeling, a pen and a whiteboard, a
sheet of paper, or a napkin is often all you need to start discussing what your data will look
like.
2.1.1. Modeling with diagrams: a simple example
Suppose that instead of friendships between individuals, you were interested in modeling
associationsbetweengroupsofpeople.Agroupmightcontainseveralpeople,andaperson
might belong to several groups. In a traditional RDBMS, you'd typically model this scen-
ario using three tables: a table for people, a table for groups, and a join table that would be
used to link people to groups in a many-to-many relationship (
figure 2.1
)
.
Figure 2.1. Users and groups in an RDBMS with a join table