GraphGists

Goal

The aim of this graphgist is to order the information about books. The idea can be used by books management systems, content recommendations systems, etc. Firstly, the designed data model is presented. Next, exemplary data is loaded and exemplary cipher queries run to show the applications of this model.

Data Model

The Book concept is the heart of the model and other entities together with relationships describe it. The model consist of the following domains and relationships:

Table 1. Domains
Domain Attributes Example

Book

title - original

Harry Potter and the Philosopher’s Stone

Book Series

title

Harry Potter

Keyword

name

magic, students

Genre

name

fantasy, mystery

Person

name, surname

J. K. Rowling

Translation

title - translated)

Harry Potter à l’Ecole des sorciers

Language

name

English, French

EBook

link

linkToHarryPotterEBook

Review

link

linkToReview1, linkToReview2

Movie

title

Harry Potter and the Philosopher’s Stone

Time

century, year, season, date

1997,

Place

continent, country, city name, address

US, UK

Publishing House

name

Bloomsbury Publishing, Arthur A. Levine Books

Table 2. Relationships
Start Node Relationship End Node Example

Book

IS_PART_OF

Book Series

Harry Potter and the Philosopher’s Stone IS_PART_OF (order no: 1) Harry Potter

Book

DESCRIBED_BY

Keyword

Harry Potter and the Philosopher’s Stone DESCRIBED_BY magic

Book

OF_TYPE

Genre

Harry Potter and the Philosopher’s Stone OF_TYPE fantasy

Book

WRITTEN_BY

Person

Harry Potter and the Philosopher’s Stone WRITTEN_BY J. K. Rowling

Book

TRANSLATED_TO

Translation

Harry Potter and the Philosopher’s Stone TRANSLATED_TO Harry Potter A L’Ecole des Sorciers

Book

HAS_ORIGINAL_LANGUAGE

Language

Harry Potter and the Philosopher’s Stone HAS_ORIGINAL_LANGUAGE English

Translation

OF_LANGUAGE

Language

Harry Potter A L’Ecole des Sorciers OF_LANGUAGE French

Translation

MADE_BY

Person

Harry Potter A L’Ecole des Sorciers MADE_BY Jean-François Ménard

Book

HAS_E_VERSION

EBook

Harry Potter and the Philosopher’s Stone HAS_E_VERSION eHarryPotter

Translation

HAS_E_VERSION

EBook

Harry Potter A L’Ecole des Sorciers HAS_E_VERSION eHarryPotterInFrench

Book

HAS_REVIEW

Review

Harry Potter and the Philosopher’s Stone HAS_REVIEW review1

Book

MADE_INTO

Movie

Harry Potter and the Philosopher’s Stone MADE_INTO Harry Potter and the Philosopher’s Stone

Book

WHEN_ACTION

Time

Harry Potter and the Philosopher’s Stone WHEN_ACTION XX century

Book

WHEN_PUBLISHED

Time

Harry Potter and the Philosopher’s Stone WHEN_PUBLISHED 1997

Book

WHERE_ACTION

Place

Harry Potter and the Philosopher’s Stone WHERE_ACTION Londyn

Book

WHERE_PUBLISHED

Place

Harry Potter and the Philosopher’s Stone WHERE_PUBLISHED UK

Book

PUBLISHED_BY

Publishing House

Harry Potter and the Philosopher’s Stone PUBLISHED_BY Bloomsbury Publishing

Graph data upload

Firstly, the test data is added to the database.

The uploaded data consists of the following books and information about them:

  • Harry Potter and the Philosophers Stone written by J. K. Rowling in English which is a part of Harry Potter series. It was published in 1997 by Bloomsbury Publishing, Arthur A. Levine Books. The book has been translated into many languages, including French. There is also a movie based on the book. The action takes place in London in contemporary times. Keywords describing the movie: magic, students.

  • The Book Thief written by Markus Zusak in English. It was first published in 2005 by Picador in Australia. The action takes place in Nazi Germany in XX century. There is also a movie based on the book. Keywords describing the movie: death, students, judaism.

  • The Adventures of Tom Sawyer written by Mark Twain in English. It was published by American Publishing Company in 1876 in US. The action takes place in US. Keywords describing the movie: boy, children's novel, change, psychology.

Applications

The data model and queries below enable retrieving information about books according to many criteria.

Find books of genre 'novel'

MATCH (b:Book)-[:OF_TYPE]->(:Genre{name:'novel'}),
       b-[:DESCRIBED_BY]->(k:Keyword)
RETURN b.title AS book, collect(k.name) as keywords
ORDER BY b.title

Find books published by 'Bloomsbury Publishing'

MATCH (b:Book)-[:PUBLISHED_BY]->(:PublishingHouse{name:'Bloomsbury Publishing'}),
       b-[:WHEN_PUBLISHED]->(t:Time),
       b-[:WHERE_PUBLISHED]->(p:Place)
RETURN b.title AS book, t.year as time, p.country as place
ORDER BY t DESC, b.title

Find books whose action takes place in 'Germany' in 'XX century'

MATCH (b:Book)-[:WHERE_ACTION]->(:Place{country:'Germany'}),
       b-[:WHEN_ACTION]->(:Time{century:'XX'})
RETURN b.title AS book
ORDER BY b.title

Find all books that has been filmed

MATCH (b:Book)-[:MADE_INTO]->(m:Movie),
       b-[:WHEN_PUBLISHED]->(t:Time)
WHERE m.title<>""
RETURN b.title AS book, t.year as time
ORDER BY t.year DESC, b.title

Find books translations into foreign languages

MATCH (b:Book)-[:TRANSLATED_TO]->(t:Translation)
RETURN DISTINCT b.title AS book, collect(t.title) as translations
ORDER BY b.title

Summary

Presented model is extendible: the information about other content can be added, e.g. about movies, audiobooks, computer games that correspond to particular books. This order information is the knowledge base about books that can be used in searching for a particular content or content recommendations. Additional layer in form of classical social network can be added to enable the functionality of profiling people according to their reading taste, finding similar people (based on their reading taste), etc. The model can be also used to prove that graph modelling of this domain and querying is much easier that in case of relational databases.