Basic graph data modeling
Basics of graph data modeling.


person
(vertex label) created
(edge) a
recipe
(vertex label). The properties are name
, used for both
a person
and a recipe
, and create_date
used as
an edge property for created
.
name
and edge property
create_date
.
DataStax Graph (DSG) supports multiplicity for both properties and edges. Multiple values for the same property can be defined with collections (set, list, map), tuples, or user-defined types (UDTs). All properties use CQL data types. Multiple edges of the same type can be constructed between two vertices if uniqueness is guaranteed by a clustering key.
Looking at the full data model, a person
vertex can have a
name
, as well as additional properties such as gender
and
nickname
. A reviewed
edge can have a multiple properties that
identify attributes of a recipe review for the adjoining recipe
. Or consider the
locations that a person has lived during their lifetime; a query can be aimed at discovering
where a person lived. Would it be interesting to know if Julia Child lived in France or the
United States while writing her first cookbook? It could be relevant if the cookbook is on French
cuisine. The tuple country
includes the country name
,
start_date
, and end_date
that can support that query. Because
Julia Child lived in multiple countries during her lifetime, the property
country
must be a data type that can store multiple countries with respective
start and end dates.
You may wonder about deciding which entities and relationships are included in a graph data model. Let's take a look in the next section.