100% found this document useful (14 votes)
4K views

Immediate Download Building Web Applications With Python and Neo4j 1st Edition Sumit Gupta Ebooks 2024

Sumit

Uploaded by

ijharhayfaa70
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (14 votes)
4K views

Immediate Download Building Web Applications With Python and Neo4j 1st Edition Sumit Gupta Ebooks 2024

Sumit

Uploaded by

ijharhayfaa70
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Get ebook downloads in full at ebookname.

com

Building Web Applications with Python and Neo4j


1st Edition Sumit Gupta

https://ebookname.com/product/building-web-applications-
with-python-and-neo4j-1st-edition-sumit-gupta/

OR CLICK BUTTON

DOWNLOAD EBOOK

Explore and download more ebook at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Building Web Apps with WordPress 1st Edition Brian


Messenlehner

https://ebookname.com/product/building-web-apps-with-
wordpress-1st-edition-brian-messenlehner/

Building Web Services with Microsoft Azure 1st Edition


Belotserkovskiy

https://ebookname.com/product/building-web-services-with-
microsoft-azure-1st-edition-belotserkovskiy/

Homogeneous Catalysis Mechanisms and Industrial


Applications 2nd Edition Sumit Bhaduri

https://ebookname.com/product/homogeneous-catalysis-mechanisms-
and-industrial-applications-2nd-edition-sumit-bhaduri/

Nutrition Immunity and Infection First Edition Prakash


Shetty

https://ebookname.com/product/nutrition-immunity-and-infection-
first-edition-prakash-shetty/
Design for Motion Fundamentals and Techniques of Motion
Design Austin Shaw

https://ebookname.com/product/design-for-motion-fundamentals-and-
techniques-of-motion-design-austin-shaw/

The Encyclopedia of Skin and Skin Disorders Facts on


File Library of Health and Living 3rd Edition Carol
Turkington

https://ebookname.com/product/the-encyclopedia-of-skin-and-skin-
disorders-facts-on-file-library-of-health-and-living-3rd-edition-
carol-turkington/

Tables of Knowledge Descartes in Vermeer s Studio


Harriet Stone

https://ebookname.com/product/tables-of-knowledge-descartes-in-
vermeer-s-studio-harriet-stone/

Gilles Deleuze 1st Edition Claire Colebrook

https://ebookname.com/product/gilles-deleuze-1st-edition-claire-
colebrook/

Teaching Intercultural Rhetoric and Technical


Communication Theories Curriculum Pedagogies and
Practice 1st Edition Barry Thatcher

https://ebookname.com/product/teaching-intercultural-rhetoric-
and-technical-communication-theories-curriculum-pedagogies-and-
practice-1st-edition-barry-thatcher/
Pick Your Yoga Practice Exploring and Understanding
Different Styles of Yoga 1st Edition Meagan Mccrary

https://ebookname.com/product/pick-your-yoga-practice-exploring-
and-understanding-different-styles-of-yoga-1st-edition-meagan-
mccrary/
Building Web Applications
with Python and Neo4j

Develop exciting real-world Python-based


web applications with Neo4j using frameworks
such as Flask, Py2neo, and Django

Sumit Gupta

BIRMINGHAM - MUMBAI
Building Web Applications with Python and Neo4j

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the author, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: July 2015

Production reference: 1100715

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78398-398-8

www.packtpub.com
Credits

Author Copy Editors


Sumit Gupta Vikrant Phadke
Alpha Singh
Reviewers
Adarsh Deshratnam Project Coordinator
Gianluca Tiepolo Izzat Contractor
Tsanyo Tsanev
Manuel Vives Proofreader
Safis Editing

Commissioning Editor
Kunal Parikh Indexer
Rekha Nair

Acquisition Editor
Larissa Pinto Production Coordinator
Aparna Bhagat

Content Development Editor


Anish Sukumaran Cover Work
Aparna Bhagat

Technical Editors
Novina Kewalramani
Ryan Kochery
Manal Pednekar
About the Author

Sumit Gupta is a seasoned professional, innovator, and technology evangelist,


with over 100 months of experience in architecting, managing, and delivering
enterprise solutions that revolve around a variety of business domains, such as
hospitality, healthcare, risk management, insurance, and so on. He is passionate
about technology, with over 14 years of hands-on experience in the software
industry. Sumit has been using big data and cloud technologies for the past
4 to 5 years to solve complex business problems.

He is also the author of Neo4j Essentials (http://neo4j.com/books/neo4j-


essentials/).

I want to acknowledge and express my gratitude to everyone


who supported me in authoring this book. I am thankful for their
inspiring guidance and valuable, constructive, and friendly advice.
About the Reviewers

Adarsh Deshratnam is a senior consultant (big data and cloud) whose focus is
on designing, developing, and deploying Hadoop solutions for many MNCs. In
this position, he has worked with customers to build several Hadoop applications
with multiple database technologies, providing a unique perspective on moving
customers beyond batch processing. An avid technologist, he focuses on technological
innovations. Since 2006, he has been working full time and part time with big data and
multiple database technologies. Adarsh completed his engineering at Staffordshire
University with a computing major.

I would like to thank Packt Publishing for giving me the wonderful


opportunity to review a book on one of the quickly evolving graph
databases (Neo4j).

Gianluca Tiepolo has been programming since Windows 3.11 was around.
As a cofounder of Sixth Sense Solutions, a start-up that is a global leader in retail
solutions, he has worked with some of the world's biggest brands to deliver engaging,
interactive experiences to their customers. He specializes in high-performance
implementations of database services and computer vision. Currently, he's deeply
involved in the open source community and has a lot of interest in big data.

I want to thank my wonderful wife, Adele; my awesome teammates;


and my friend Marco for their support and inspiration.
Tsanyo Tsanev is a senior web developer at Dressler LLC in New York, USA.
From the whiteboard to production, he has experience in building a variety of web
applications. He began experimenting with Neo4j for the social networking website
SongSilo and has since found many other uses for it. Tsanyo's passion is coding;
he does it both for a living and as a hobby.

Manuel Vives is a software engineer, who focuses on Python and C++.


He specializes in backend parts of distributed software and NoSQL databases.
He used to work in France for a company that specializes in cybersecurity and
training, and he now works in Canada.
www.PacktPub.com

Support files, eBooks, discount offers, and more


For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF
and ePub files available? You can upgrade to the eBook version at www.PacktPub.
com and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign
up for a range of free newsletters and receive exclusive discounts and offers on Packt
books and eBooks.
TM

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print, and bookmark content
• On demand and accessible via a web browser

Free access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view 9 entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface v
Chapter 1: Your First Query with Neo4j 1
Thinking in graphs for SQL developers 2
Comparing SQL and Cypher 3
Evolving graph structures from SQL models 5
Licensing and configuring – Neo4j 8
Licensing – Community Edition 8
Licensing – Enterprise Edition 8
Installing Neo4J Community Edition on Linux/Unix 9
Installing as a Linux tar / standalone application 10
Installing as a Linux service 11
Installing Neo4j Enterprise Edition on Unix/Linux 12
Using the Neo4j shell 14
Introducing the Neo4j REST interface 16
Authorization and authentication 16
CRUD operations 17
Running queries from the Neo4j browser 20
Summary 21
Chapter 2: Querying the Graph with Cypher 23
Basic anatomy of a Cypher query 24
Brief details of Cypher 24
Cypher execution phases 25
Parsing, validating, and generating the execution plan 25
Locating the initial node(s) 26
Selecting and traversing the relationships 26
Changing and/or returning the values 26
The structure of Cypher 26
The read operations 27

[i]
Table of Contents

The create or update operations 30


The delete operation 32
Pattern and pattern matching 32
Sample dataset 32
Pattern for nodes 34
Pattern for labels 34
Pattern for relationships 34
Pattern for properties 35
Using the where clause with patterns 35
Using patterns in the where clause 36
Using general clauses with patterns 36
The order by clause 37
The limit and skip clauses 37
The WITH clause 37
The UNION and UNION ALL clauses 38
Working with nodes and relationships 39
Summary 43
Chapter 3: Mutating Graph with Cypher 45
Creating nodes and relationships 46
Working with nodes 46
Single node 46
Multiple nodes 48
Node with labels 48
Node with properties 49
Working with relationships 51
Single relationships 51
Multiple relationships 52
Relationships with properties 54
Nodes and relationships with full paths 55
Creating unique nodes and relationships 55
CREATE UNIQUE and MERGE 55
Working with constraints 56
Transforming nodes and relationships 57
Updating node properties 57
Updating a label 58
Updating relationships 58
Cypher query optimizations 58
Indexes 59
Index sampling 61
Understanding execution plans 62
Analyzing and optimizing queries 64
Summary 66

[ ii ]
Table of Contents

Chapter 4: Getting Python and Neo4j to Talk Py2neo 67


Installing and configuring py2neo 68
Prerequisites 68
Installing py2neo 69
Exploring the py2neo APIs 70
Graph 70
Authentication 71
Node 72
Relationship 75
Cypher 77
Transactions 80
Paths 81
Creating a social network with py2neo 83
Batch imports 86
Unit testing 88
Summary 91
Chapter 5: Build RESTful Service with Flask and Py2neo 93
Introducing (and installing) Flask 94
Setting up web applications with Flask and Flask-RESTful 96
Your first Flask application 96
Displaying static content 98
Displaying dynamic content 99
Your first Flask RESTful API 101
JSON processing 102
REST APIs for social network data using py2neo 104
ORM for graph databases py2neo – OGM 104
Social network application with Flask-RESTful and OGM 106
Creating object model 106
Creating REST APIs over data models 110
Summary 114
Chapter 6: Using Neo4j with Django and Neomodel 115
Installing and configuring Neomodel 116
Declaring models and properties 118
Defining nodes 118
Defining properties 119
Persisting and querying a social data model 121
Adding relationships to models 125
Running Cypher queries 129
Using Neomodel in a Django app 130
Signals in Neomodel 131
Summary 132

[ iii ]
Table of Contents

Chapter 7: Deploying Neo4j in Production 133


Neo4j logical architecture 134
Disk/filesystem 135
Record files 135
Transaction logs 137
Caches 137
Core Java API 139
Traversal framework 140
REST API 141
Neo4j physical architecture 142
High availability 142
Fault tolerance 144
Data replication and data locality 145
Advanced settings 146
Monitoring the health of the Neo4J nodes 147
Neo4j browser 148
Webadmin 148
JMX beans 149
Backup and recovery 152
Summary 153
Index 155

[ iv ]
Preface
Relational databases have been one of the most widely used and most common
forms of software systems for the storage of data since the 1970s. They are highly
structured and store data in the form of tables, that is, with rows and columns.
Structuring and storing data in the form of rows and columns has its own
advantages; for example, it is easier to understand and locate data, reduce data
redundancy by applying normalization, maintain data integrity, and much more.

But is this the best way to store any kind of data?

Let's consider an example of social networking:

Mike, John, and Claudia are friends. Claudia is married to Wilson. Mike and Wilson
work for the same company.

Here is one of the possible ways to structure this data in a relational database:

[v]
Preface

Complex, isn't it? And it can be more complex!

We should remember that relationships are evolving, and will evolve over a period
of time. There could be new relationships, or there could be changes to existing
relationships.

We can design a better structure but in any case, wouldn't that be forcibly fitting the
model into a structure?

RDBMS is good for use cases where the relationship between entities is more or less
static and does not change over a period of time. Moreover, the focus of RDBMS is
more on the entities and less on the relationships between them.

There could be many more examples where RDBMS may not be the right choice:

1. Model and store 7 billion people objects and 3 billion non-people objects to
provide an "earth view" drill-down from the planet to a sidewalk
2. Network management
3. Genealogy
4. Public transport links and road maps

Consider another way of modelling the same data:

Simple, isn't it?

Welcome to the world of Neo4j—a graph database.

[ vi ]
Preface

Although there is no single definition of graphs, here is the simplest one (http://
en.wikipedia.org/wiki/Graph_(abstract_data_type)), which helps us to
understand the theory of graphs:

A graph data structure consists of a finite (and possibly mutable) set of nodes or
vertices, together with a set of ordered pairs of these nodes (or, in some cases, a set
of unordered pairs). These pairs are known as edges or arcs. As in mathematics,
an edge (x,y) is said to point or go from x to y. The nodes may be part of the graph
structure, or may be external entities represented by integer indices or references.

Neo4j, as an open source graph database, is part of the NoSQL family, and provides
a flexible data structure, where the focus is on the relationships between the entities
rather than the entities themselves.

Its first version (1.0) was released in February 2010, and since then, it has never
stopped. It is amazing to see the pace at which Neo4J has evolved over the years. At
the time of writing this book, the stable version was 2.2.RC01, which was released in
March 2015.

If you are reading this book, then you probably already have sufficient knowledge
about graph databases and Python. You will appreciate their contribution to the
complex world of relationships.

Let's move forward and jump into the nitty-gritty of developing web applications
with Python and Neo4j.

In the subsequent chapters, we will cover the various aspects dealing with data
modelling, programming, and data analysis by means of application development
with Python and Neo4j. We will cover the concepts of working with py2neo, Django,
flask, and many more.

What this book covers


Chapter 1, Your First Query with Neo4j, details the process of the installation of Neo4j
and Python on Windows and Linux. This chapter briefly explains the function
of every tool installed together with Neo4j (shell, server, and browser). More
importantly, it introduces, and helps you get familiar with, the Neo4j browser. You
get to run the first basic Cypher query by using different methods exposed by Neo4j
(shell, Java, the browser, and REST).

[ vii ]
Preface

Chapter 2, Querying the Graph with Cypher, starts by explaining Cypher as a graph
query language for Neo4j, and then we take a deep dive into the various Cypher
constructs to perform read operations. This chapter also talks about the importance
of patterns and pattern matching, and their usage in Cypher with various real-world
and easy-to-understand examples.

Chapter 3, Mutating Graph with Cypher, starts by covering the Cypher constructs
used to perform write operations on the Neo4j database. This chapter further talks
about creating relationships between nodes and discusses the constraints required
for maintaining the integrity of data. At the end, it discuss about the performance
tuning of Cypher queries using various optimization techniques.

Chapter 4, Getting Python and Neo4j to Talk Py2neo, introduces Py2neo as a Python
framework for working with Neo4j. This chapter explores various Python APIs
exposed by Py2neo for working with Neo4j. It also talks about batch imports
and introduces a social network use case, which is created and unit tested by
using Py2neo APIs.

Chapter 5, Build RESTful Service with Flask and Py2neo, talks about building web
applications and the integration of Flask and Py2neo. This chapter starts with the
basics of Flask as a framework for exposing ReSTful APIs, and further talks about
the Py2neo extension OGM (short for Object Graph Mapper) and its integration with
Flask for performing various CRUD and search operations on the social network use
case by creating and leveraging various ReST endpoints.

Chapter 6, Using Neo4j with Django and Neomodel, starts by describing Neomodel as
an ORM for Neo4j. It discusses various high-level APIs exposed by Neomodel to
perform CRUD and search operations using Python APIs or by directly executing
Cypher queries. Finally, it talks about integration of two of the popular Python
frameworks, Django and Neomodel.

Chapter 7, Deploying Neo4j in Production, explains the logical architecture of Neo4j,


its various components, or APIs, such as filesystems, data organization and so
on. Then we move on to the physical architecture of Neo4j, where we talk about
meeting various NFRs imposed by typical enterprise deployments, such as HA,
fault tolerance, data locality, backup, and recovery. Further, this chapter talks
about various advanced Neo4j configurations and also discusses the various
ways to monitor our Neo4j deployments.

[ viii ]
Preface

What you need for this book


Readers should have programming experience in Python and some basic knowledge
or understanding of any graph or NoSQL databases.

Who this book is for


This book is aimed at competent developers who have a good knowledge and
understanding of Python that can allow efficient programming of the core elements
and applications.

If you are reading this book, then you probably already have sufficient knowledge
of Python. This book will cover data modelling, programming, and data analysis by
means of application development with Python and Neo4j. It will cover concepts
such as working with py2neo, Django, flask, and so on.

Conventions
In this book, you will find a number of text styles that distinguish between different
kinds of information. Here are some examples of these styles and an explanation of
their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
"We can include other contexts through the use of the include directive."

A block of code is set as follows:


MATCH (x { name: "Bradley" })--(y)-->()
WITH x
CREATE (n:Male {name:"Smith", Age:"24"})-[r:FRIEND]->(x)
returnn,r,x;

Any command-line input or output is written as follows:


pip install flask Flask-RESTful

New terms and important words are shown in bold. Words that you see on the
screen, for example, in menus or dialog boxes, appear in the text like this: "Now,
click on the star sign in the panel on the extreme left-hand side, and click on
Create a node in the provided menu."

[ ix ]
Preface

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail feedback@packtpub.com, and mention


the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.

Downloading the example code


You can download the example code files from your account at http://www.
packtpub.com for all the Packt Publishing books you have purchased. If you
purchased this book elsewhere, you can visit http://www.packtpub.com/support
and register to have the files e-mailed directly to you.

[x]
Preface

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you could report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/submit-errata, selecting your book, clicking on the Errata Submission Form
link, and entering the details of your errata. Once your errata are verified, your
submission will be accepted and the errata will be uploaded to our website or added
to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the book in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected


pirated material.

We appreciate your help in protecting our authors and our ability to bring you
valuable content.

Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.

[ xi ]
Chapter 1

Your First Query with Neo4j


Neo4j is a graph database and has been in commercial development for over a
decade. It comes with several flavors, supporting a wide variety of use cases and
requirements imposed by start-ups, large enterprises, and Fortune 500 customers.
It is a fully transactional database; it supports Atomicity, Consistency, Isolation,
Durability (ACID) and is also well equipped to handle the complexities introduced
by various kinds of systems—web-based, online transaction processing (OLTP),
data-warehousing, analytics, and so on.

This chapter will help you to understand the paradigm, applicability, various
aspects, and characteristics of Neo4j as a graph database. It will guide you through
the installation process, starting right from downloading and running your first
Cypher query leveraging various interfaces/tools/utilities exposed by Neo4j
against your fully-working instance.

At the end of this chapter, your work environment will be fully functional, and
you will be able to write your first Cypher query to insert/fetch the data from the
Neo4j database.

This chapter will cover the following points:

• Thinking in graphs for SQL developers


• Licensing and configuring – Neo4j
• Using the Neo4j shell
• Introducing the Neo4j REST interface
• Running queries from the Neo4j browser

[1]
Your First Query with Neo4j

Thinking in graphs for SQL developers


Some might say that it is difficult for SQL developers to understand the paradigm of
graphs, but it is not entirely true. The underlying essence of data modeling does not
change. The focus is still on the entities and the relationship between these entities.
Having said that, let's discuss the pros/cons, applicability, and similarity of the
relational models and graph models.

The relational models are schema-oriented. If you know the structure of data
in advance, it is easy to ensure that data conforms to it, and at the same time, it
helps in enforcing stronger integrity. Some examples include traditional business
applications, such as flight reservations, payroll, order processing, and many more.

The graph models are occurrence-oriented—Probabilistic model. They are adaptive


and define a generic data structure that is evolving and works well with scenarios
where the schema is not known in advance. The graph model is perfectly suited to
store, manage, and extract highly-connected data.

Let's briefly discuss the disadvantages of the SQL databases, which led to the
evolution of the graph databases:

• It is difficult to develop efficient models for evolving data, such as social


networks
• The focus is more on the structure of data than the relationships
• They lack an efficient mechanism for performing recursions

All the preceding reasons were sufficient to design a different data structure, and as
a result, the graph data structures were introduced.

The objective of the graph databases was specifically to meet the disadvantages
of the SQL databases. However, Neo4j as a graph database, also leveraged the
advantages of the SQL databases wherever possible and applicable. Let's see a
few of the similarities between the SQL and graph databases:

• Highly Consistent: At any point in time, all nodes contain the same data at
the same time
• Transactional: All insert or update operations are within a transaction where
they are ACID

Having said that, it is not wrong to say that the graph databases are more or less the
next generation of relational databases.

[2]
Chapter 1

Comparing SQL and Cypher


Every database has its own query languages; for example, RDBMS leverages SQL
and conforms to SQL-92 (http://en.wikipedia.org/wiki/SQL-92). Similarly,
Neo4j also has its own query language—Cypher. The syntax of Cypher has
similarities with SQL, though it still has its own unique characteristics, which
we will discuss in the upcoming sections.

Neo4j leveraged the concept of patterns and pattern matching, and introduced a new
declarative graph query language, Cypher, for the Neo4j graph database. Patterns
and pattern matching are the essence and core of Neo4j, so let's take a moment to
understand them. We will then talk about the similarities between SQL and Cypher.

Patterns are a given sequence or occurrence of tokens in a particular format. The act
of matching patterns within a given sequence of characters or any other compatible
input form is known as pattern matching. Pattern matching should not be confused
with pattern recognition, which usually produces the exact match and does not have
any concept of partial matches.

Pattern matching is the heart of Cypher and a very important component of the
graph databases. It helps in searching and identifying a single or a group of nodes
by walking along the graph. Refer to http://en.wikipedia.org/wiki/Pattern_
matching for more information on the importance of pattern matching in graphs.
Let's move forward and talk about Cypher, and it's similarities with SQL.

Cypher is specifically designed to be a human query language, which is focused


on making things simpler for developers. Cypher is a declarative language and
implements "What to retrieve" and not "how to retrieve", which is in contrast to
the other imperative languages, such as Java and Gremlin (refer to http://gremlin.
tinkerpop.com/).

Cypher borrows much of its structure from SQL, which makes it easy to use/
understand for SQL developers. "SQL familiarity" is another objective of Cypher.

[3]
Your First Query with Neo4j

Let's refer to the following illustration, which defines the Cypher constructs and the
similarity of Cypher with SQL constructs:

The preceding diagram defines the mapping of the common SQL and Cypher
constructs. It also depicts the examples stating the usage of these constructs.

For instance, FROM is similar to MATCH or START and produces the same results.
Although the way they are used is different but the objective and concept remains
the same.

We will talk about Cypher in detail in Chapter 2, Querying the Graph with Cypher and
Chapter 3, Mutating Graph with Cypher, but without getting into the nitty-gritty and
syntactical details. The following is one more illustration that briefly describes the
similarities between the Cypher and SQL constructs:

[4]
Chapter 1

In the preceding illustration, we are retrieving the data using Cypher pattern
matching. In the statement shown in the preceding diagram, we are retrieving all
the nodes that are labeled with FEMALE in our Neo4j database. This statement is very
similar to the SQL statement where we want to retrieve some specific rows of a table
based on a given criteria, such as the following query:
SELECT * from EMPLOYEE where GENDER = 'FEMALE'

The preceding examples should be sufficient to understand that SQL developers can
learn Cypher in no time.

Let's take one more example where we want to retrieve the total number of
employees in the company X:

• SQL syntax: Select count (EMP-ID) from Employee where COMPANY_


NAME='X'
• Cypher syntax: match (n) where n.CompanyName='X' return count(n);

The preceding Cypher query shows the usage of aggregations such as count, which
can also be replaced by sum, avg, min, max, and so on.

Refer to http://neo4j.com/docs/stable/query-aggregation.
html for further information on aggregations in Cypher.

Let's move forward and discuss the transformation of the SQL data structures into
the graph data structures.

Evolving graph structures from SQL models


The relational models are the simplest models to depict and define the entities and
the relationship between those entities. It is easy to understand and you can quickly
whiteboard with your colleagues and domain experts.

A graph model is similar to a relational model as both models are focused on the
domain and use case. However, there is a substantial difference in the way they are
created and defined. We will discuss the way the graph models are derived from
the relational models, but before that, let's look at the important components of the
graph models:

• Nodes: This component represents entities such as people, businesses,


accounts, or any other item you might want to keep track of.

[5]
Your First Query with Neo4j

• Labels: This component is the tag that defines the category of nodes. There
can be one or more labels on a node. A label also helps in creating indexes,
which further help in faster retrievals. We will discuss this in Chapter 3,
Mutating Graph with Cypher.
• Relationship: This component is the line that defines the connection between
the two nodes. Relationship can further have its own properties and direction.
• Properties: This component is pertinent information that relates to the nodes.
This can be applied to a node or the relationship.

Let's take an example of a relational model, which is about an organization, and then
understand the process of converting this into a graph model:

In the preceding relational model, we have employee, department, and title as


entities, and Emp-Dept and Emp-Title as the relationship tables.

Here is sample data within this model:

[6]
Chapter 1

The preceding screenshot depicts the sample data within the relational structures.
The following are the guidelines to convert the preceding relational model into the
graph model:

• The entity table is represented by a label on nodes


• Each row in an entity table is a node
• The columns on these tables become the node properties
• The foreign keys and the join tables are transformed into relationships;
columns on these tables become the relationship properties

Now, let's follow the preceding guidelines and convert our relational model into the
graph model, which will look something like the below image:

The preceding illustration defines the complete process and the organization of
data residing in the relational models into the graph models. We can use the same
guidelines for transforming a variety of relational models into the graph structures.

In this section, we discussed the similarities between SQL and Cypher. We also
talked and discussed about the rules and processes of transforming the relational
models into graph models. Let's move forward and understand the licensing and
installation procedure of Neo4j.

[7]
Your First Query with Neo4j

Licensing and configuring – Neo4j


Neo4j is an open source graph database, which means all its sources are available to
the public (currently on GitHub at https://github.com/neo4j/neo4j). However,
Neo Technology, the company behind Neo4j, distributes the latter in two different
editions—the Community edition and Enterprise edition. Let's briefly discuss the
licensing policy for the Community and Enterprise editions, and then we will talk
about the installation procedures on the Unix/Linux operating systems.

Licensing – Community Edition


Community Edition is a single node installation licensed under General Public
License (GPL) Version 3 (http://en.wikipedia.org/wiki/GNU_General_Public_
License) and is used for the following purposes:

• Preproduction environments, such as development or QA for fast paced


developments
• Small to medium scale applications where it is preferred to embed the
database within the existing application
• Research and development where advanced monitoring and high
performance is not the focus

You can benefit from the support of the whole Neo4j community on Stack Overflow,
Google Groups, and Twitter.

If you plan to ask a question on Stack Overflow, do not


forget to tag your question with the #Neo4j hashtag.

Licensing – Enterprise Edition


Enterprise Edition comes with three different kinds of subscription options and
provides the distributed deployment of the Neo4j databases, along with various
other features, such as backup, recovery, replication, and so on.

• Personal license: It is free of charge and may look very similar to


Community Edition. It targets students, as well as small businesses.

[8]
Chapter 1

• Startup program: Starting from this plan, you can benefit from the enterprise
support. A startup license allows workday support hours—10 hours per 5
business days.
• Enterprise subscriptions: With this plan, you can benefit from 24/7 support
and emergency custom patches if needed. At this scale, your company
will have to directly contact Neo Technology to assess the cost of your
required setup.

The license defines instance as the Java Virtual


Machine hosting a Neo4j server.

Each of the subscription is subject to its own license and pricing. Visit http://
neo4j.com/subscriptions/ for more information about available subscriptions
with Enterprise Edition.

Installing Neo4J Community Edition on


Linux/Unix
In this section, we will talk about the Neo4j installation on the Linux/Unix operating
system. At the end of this section, you will have a fully-functional Neo4j instance
running on your Linux/Unix desktop/server.

Let's perform the following common steps involved in the Neo4j installation on
Linux/Unix:

1. Download and install Oracle Java 7 (http://www.oracle.com/


technetwork/java/javase/install-linux-self-extracting-138783.
html) or open JDK 7 (https://jdk7.java.net/download.html).
2. Set JAVA_HOME as an environment variable and the value of this variable will
be the file system path of your JDK installation directory:
export JAVA_HOME=<Path of Java install Dir>

[9]
Your First Query with Neo4j

3. Download the stable release of the Linux distribution, neo4j-community-


2.2.0-RC01-unix.tar.gz, from http://neo4j.com/download/other-
releases/.

Neo4j can be installed and executed as a Linux service, or it can also be downloaded
as the .tar file, where, after installation, it needs to be started manually.

Let's talk about the steps involved in installing Neo4j as a service, and then we will
also talk about the standalone archive.

Installing as a Linux tar / standalone application


Architects have always preferred to install critical applications as a Linux service,
but there can be reasons, such as insufficient privileges, which restrict you from
installing software as a Linux service. So, whenever you cannot install software as
a Linux service, there is another way in which you can download Neo4j, perform
manual configuration, and start using it.

Let's perform the following steps to install Neo4j as a Linux tar / standalone
application:
1. Once you have downloaded the Neo4j archive, browse the directory from
where you want to extract the Neo4j server and untar the Linux/Unix
archive: tar –xf <location of Archive file>. Let's refer to the
top-level extracted directory as $NEO4J_HOME.
2. Open the Linux shell or console and execute the following commands for
starting the sever:
°° <$NEO4J_HOME>/bin/neo4j - start: This command is used for
running the server in a new process

[ 10 ]
Chapter 1

°° <$NEO4J_HOME>/bin/neo4j - console: This command is used for


running the server in the same process or window without forking a
new process
°° <$NEO4J_HOME>/bin/neo4j - restart: This command is used for
restarting the server

3. Browse http://localhost:7474/browser/ and you will see the login


screen of the Neo4j browser.
4. Enter the default username/password as neo4j/neo4j and press Enter. The
next screen will ask you to change the default password.
5. Change the password and make sure that you remember it. We will use this
new password in the upcoming examples.
6. Stop the server by pressing Ctrl + C or by typing <$NEO4J_HOME>/bin/neo4j
- stop.

Installing as a Linux service


This is the most preferred procedure for installing Neo4j in all kinds of
environments, whether it's production, development, or QA. Installing Neo4j as a
Linux service helps a Neo4j server and database to be available for use at server
start-up and also survive user logons/logoffs. It also provides various other benefits
such as ease of installation, configuration, and up-gradation.

Let's perform the following steps and install Neo4j as a Linux service:

1. Once the Neo4j archive is downloaded, browse the directory from where
you want to extract the Neo4j server and untar the Linux/Unix archive:
tar –xf <location of Archive file>. Let's refer to the top-level
extracted directory as $NEO4J_HOME.
2. Change the directory to $NEO4J_HOME; and execute the command, sudo bin/
neo4j neo4j-installer install; and follow the steps as they appear on
the screen.

The installation procedure will provide an option to


select the user that will be used to run the Neo4j server.
You can supply any existing or new Linux user (defaults
to Neo4j). If a user is not present, it will be created as a
system account and the ownership of <$NEO4J_HOME>/
data will be moved to that user.

[ 11 ]
Your First Query with Neo4j

3. Once the installation is successfully completed, execute sudo service


neo4j-service start on the Linux console for starting the server and
sudo service neo4j-service stop for gracefully stopping the server.
4. Browse http://localhost:7474/browser/ and you will see the login
screen of the Neo4j browser.
5. Enter the default username/password as neo4j/neo4j and press Enter. The
next screen will ask you to change the default password.
6. Change the password and make sure that you remember it. We will use this
new password in the upcoming examples.

To access the Neo4j browser on remote machines, enable


and modify org.neo4j.server.webserver.address
in neo4j-server.properties and restart the server.

Installing Neo4j Enterprise Edition on


Unix/Linux
High availability, fault tolerance, replication, backup, and recovery are a few of the
notable features provided by Neo4j Enterprise Edition. Setting up a cluster of Neo4j
nodes is quite similar to the single node setup, except for a few properties which
need to be modified for the identification of node in a cluster.

Let's perform the following steps for installing Neo4j Enterprise Edition on Linux:

1. Download and install Oracle Java 7 (http://www.oracle.com/


technetwork/java/javase/install-linux-self-extracting-138783.
html) or open JDK 7 (https://jdk7.java.net/download.html).
2. Set JAVA_HOME as the environment variable and the value of this variable will
be the file system path of your JDK installation directory:
export JAVA_HOME=<Path of Java install Dir>

3. Download the stable release of the Linux distribution, neo4j-community-


2.2.0-RC01-unix.tar.gz from http://neo4j.com/download/other-
releases/.
4. Once downloaded, extract the archive into any of the selected folders and
let's refer to the top-level extracted directory as $NEO4J_HOME.

[ 12 ]
Chapter 1

5. Open <$NEO4J_HOME>\conf\neo4j-server.properties and enable/modify


the following properties:
°° org.neo4j.server.database.mode=HA: Keep this value as HA,
which means high availability. You can run it as a standalone
too by providing the value as SINGLE.
°° org.neo4j.server.webserver.address=0.0.0.0: This property
enables and provides the IP of the node for enabling remote access.

6. Open <$NEO4J_HOME>\conf\neo4j.properties and enable/modify the


following properties:
°° ha.server_id=: This property is the unique ID of each node that will
participate in the cluster. It should be an integer (1, 2, or 3).
°° ha.cluster_server=192.168.0.1:5001: This property is the IP
address and port for communicating the cluster status information
with other instances.
°° ha.server=192.168.0.1:6001: This property is the IP address
and port for the node for communicating the transactional data
with other instances.
°° ha.initial_hosts=192.168.0.1:5001,192.168.0.2:5001: This
property is a comma-separated list of host:port (ha.cluster_
server) where all nodes will be listening. This will be the same
for all the nodes participating in the same cluster.
°° remote_shell_enabled=true: Enable this property for connecting
the server remotely through the shell.
°° remote_shell_host=127.0.0.1: This property enables and provides
an IP address where remote shell will be listening.
°° remote_shell_port=1337: This property enables and provides the
port at which shell will listen. You can keep it as default in case the
default port is not being used by any other process.

7. Open <$NEO4J_HOME>/bin, execute ./neo4j start and you are done. Stop
the server by pressing Ctrl + C or by typing ./neo4j stop.
8. Browse http://<IP>:7474/browser/ for interactive shell, and on the
login screen, enter the default username/password as neo4j/neo4j and
press Enter.
9. The next screen will ask you to change the default password. Change
the password and make sure that you remember it. We will use this new
password in the upcoming examples.

[ 13 ]
Your First Query with Neo4j

Using the Neo4j shell


The Neo4j shell is a powerful interactive shell for interacting with the Neo4j
database. It is used for performing the CRUD operations on graphs.

The Neo4j shell can be executed locally (on the same machine on which we have
installed the Neo4j server) or remotely (by connecting the Neo4j shell to a remote sever).

By default, the Neo4j shell (<$NEO4J_HOME>/bin/neo4j-shell) can be executed


on the same machine on which the Neo4j server is installed, but the following
configuration changes are required in <$NEO4J_HOME>/conf/neo4j.properties
to enable the connectivity of the Neo4j database from the remote machines:

• remote_shell_enabled=true: This configuration enables the property


• remote_shell_host=127.0.0.1: This configuration enables and provides
the IP address of the machine on which the Neo4j server is installed
• remote_shell_port=1337: This configuration enables and defines the port
for incoming connections

Let's talk about various other options provided by the Neo4j shell for connecting
to the local Neo4j server:

• neo4j-shell -path <PATH>: This option shows the path of the database
directory on the local file system. A new database will be created in case
the given path does not contain a valid Neo4j database.
• neo4j-shell -pid <PID>: This option connects to a specific process ID.
• neo4j-shell -readonly: This option connects to the local database in the
READ ONLY mode.
• neo4j-shell -c <COMMAND>: This option executes a single Cypher
statement and then the shell exits.
• neo4j-shell -file <FILE >: This option reads the contents of the file
(multiple Cypher CRUD operations), and then executes it.
• neo4j-shell –config - <CONFIG>: This option reads the given
configuration file (such as neo4j-server.properties) from the
specified location, and then starts the shell.

The following are the options for connecting to the remote Neo4j server:

• neo4j-shell -port <PORT>: This option connects to the server running on


a port different to the default port (1337)
• neo4j-shell -host <HOST>: This option shows the IP address or domain
name of the remote host on which the Neo4j server is installed and running.

[ 14 ]
Another Random Document on
Scribd Without Any Related Topics
230. Pascual de Gayangos. Cartas y Relaciones de Hernán Cortés al
Emperador Carlos V. París. 1866. Pág. 196.
231. Op. cit., pág. 166.
232. Op. cit. pág. 137.
233. Op. cit. pág. 255.
234. A. H. Keane. Central and South America. 1878. Sayce. Science of
Language. 1886. A. H. Keane. Indians Americans. 1903.
235. P. Sagot. Vocabulaire Francais—Arrouge. Paris. 1882.
236. Hernhutes de Zittau.—Vocabulaire Arrouge—Allemand. Paris. 1882.
237. Th. Schulz. Grammaire Arrouge. París. 1882.
238. R. Breton. Op. cit.
239. Raymond Breton. Op. cit.
240. Voyage du Pere Labat aux isles de l’Amerique. La Haye. 1724. En el t. 2°
p. 123 dice: “Ils reconnoissent du moins confusement deux principes, l’un bon et
l’autre manvais.” J. Ballet. Les Caraibes. Congrés intern. des Americanistes. Nancy.
1875 t. 1° pág. 433.
241. Revue des Deux Mondes. S. Champlain.—Voyages et Descouvertry. París.
1620.
242. La ou francesa tiene sonido de ú española.
243. Ihering.—Prehist. de los indo-europeos. Madrid. 1896.
244. Schleicher.—Jahrbücher fur Nationalokonomie.
245. Diario de bitácora de Cristóbal Colón del primer viaje.—Anotación del
Domingo 16 de Diciembre de 1492.
246. Edición de Viena, tipografía imperial y real de la Corte.—1868.
247. Pedro Mártir de Anglería. Década II. cap. IV.
248. Véanse estas palabras indo-antillanas en el Vocabulario.
249. Guayama—Gua-yara-ma: gua, este; yara, sitio; y ma, grande. Este sitio
grande.
250. Canuy—Canua-ní: canua, canoa; ní, agua. Es decir, canoa y agua. Hoy
sintetizamos la idea en el español pasaje.
251. Guanajibo—Gua-sabana-ní-abo: gua, he aquí, na, por sabana, llano; ji,
por ní, agua; bo por abo, lugar. He aquí un lugar llano con agua. Como si di
dijéramos: Buen sitio de labranza. Una de las ideas principales del boriqueño era
buscar en la isla buenos sitios donde sembrar sus yucubías y sus ajes y batatas. Así
como elegir los lugares de agua abundante para sus baños, después del juego de
pelota.
252. Según el moderno viajero doctor Crévaux, también los tarumas, trios,
rucuyús, apalais y carijonas llaman al agua tuna. Y según Segarra y Juliá (Costa
Rica. 1907. pág. 585) los indios guatusos la llaman tí y las otras tribus indígenas de
Costa Rica, dí.
253. Arístides Rojas.—El padre nuestro en lenguas venezolanas.—Caracas.
1878.
254. Fray Matías Ruíz Blanco.—Conversión en Piritú (Colombia) de los indios
cumanagotos y palenques. Nueva edición matritense. 1892, pág. 162.
255. R. Breton.—Ob. cit., p. 35.
256. Lucien Adam. Matériaux pour servir à l’établissement d’une grammaire
comparée des dialectes de la famille Caribe. París. 1893, pág. 32.
257. Cayetano Coll y Toste. Rep. hist. de Puerto Rico. 1896. pág. 17.
258. Arístides Rojas.—Ob. cit.
259. Pbro. Rafael Celedón.—Gramática de la lengua koggaba. París. 1886.
260. Don Pedro Tomás de Córdova guarda silencio sobre este particular en sus
Memorias, porque era un empleado muy adicto á la Monarquía absoluta. Carlos
Espinosa fué un general, gobernador de Cádiz y capitán general de Andalucía, muy
adicto á los principios liberales. Se distinguió en la guerra de la Independencia y
mandó el ejército constitucional de Navarra en 1822. Murió de avanzada edad, en
1850. Juan Díaz Porlier, fué uno de los mártires de la libertad española. Nació en
Cartajena de Indias, en 1775. Se halló de guardia marina en Trafalgar. Fué mariscal
de campo en la guerra de la Independencia. Combatió el despotismo de Fernando
VII de abolir la Constitución. Fué preso. Se sublevó en Septiembre de 1815. Le
nombraron presidente de la junta revolucionaria de Galicia. Cayó prisionero y fué
ahorcado en la Coruña el 3 de Octubre del mismo año. La tremenda reacción
borbónica hizo desaparecer de la topografía de Puerto Rico los nombres de estos
tres ilustres generales españoles, salvándose Lacy en un anagrama y quedando el
nombre del general Espinosa en un barrio de Vega Alta. Del bravo Porlier no
queda recuerdo alguno.
TRANSCRIBER’S NOTESNOTAS
DEL TRANSCRIPTOR
Página Cambiado de Cambiado a
vi de Tierra Firme á de Tierra Firme á una
una franca paz, franca paz, como al
como al principio, principio, porque las
por que las expediciones
expediciones
vi Iñigo Abbad.— Íñigo Abbad.—
Facultades mentales Facultades mentales del
del aborigen.—La aborigen.—La vida en
vida en tribu ó tribu ó
7 una línea casi una línea casi regular,
regular, que sirva de que sirva de limite en
límite en este este
11 por que el terreno porque el terreno que
que corresponde á corresponde á este
este período período apareció muy
apareció muy netamente y con gran
netamente y con extensión en
gran extensión en Devonshire, Inglaterra.
Devonsgire, L. Figuier. La terre
Inglaterra. L. avant le déluge. París
Figuier. La terre
avant le déluge.
Paris
13 L. Figuier. La terre L. Figuier. La terre
avant le deluge. avant le déluge. París.
París. 1863 1863
16 contemporánea de contemporánea de
piedras se produce piedras se produce
ámpliamente ampliamente
16 estos acinamientos estos hacinamientos
calizos calizos
18 induce á creer, induce á creer, según la
según la ley ley geognóstica de Elie
geognósica de Elie de
de
18 J. B. Elie de J. B. Elie de Beaumont.
Beaumont. Notice Notice sur les systèmes
sur le systeme des de montagnes. París.
montagnes. París. 1852. Esta ley
1852. Esta ley
19 Dou Julio L. Don Julio L.
Vizcarrondo (Viaje á Vizcarrondo (Viaje á la
la isla de Puerto isla de Puerto Rico, el
Rico, el año de 1797, año de 1797, por Ledru
por Ledru y y
23 zonas. Los terrenos zonas. Los terrenos
compredidos en la comprendidos en la
zona N. y en zona N. y en
24 contíguos á la contiguos á la carretera
carretera central, en central, en los cortes de
los cortes de
25 granito granito desprendidos,
desprendidos, han han sido producidos por
sido producido por la dislocación
la dislocación
25 antidiluvianos por antediluvianos por estos
estos territorios. En territorios. En un
un
36 Hallado en Bayaney, Hallada en Bayaney,
Hatillo. Hatillo.
39 descubridor, en descubridor, en estado
estado nómade, á nómada, á semejanza
semejanza de las de las
51 americano. En un americano. En un
principio, creimos principio, creímos que
que
53 El triunfo de los El triunfo de los
invasores hnbiera invasores hubiera sido
sido seguro en seguro en
56 Monquin-Tandon Moquin-Tandon siguió
siguió á Cuvier. á Cuvier. Dumeril
Dumeriel
56 Malte Brun clasificó Malte-Brun clasificó al
al hombre en diez y hombre en diez y seis
seis
56 Cuvier. Reyne Cuvier. Règne animal,
animal, ed. 2ª t. 1º, ed. 2ª t. 1º, pág. 84.
pág. 84. París. 1829 París. 1829
56 Malte Brum. Malte-Brun.
Geographie, etc. Géographie, etc. París.
París. 1803–7 1803–7
56 Bory de Saint- Bory de Saint-Vicent.
Vicent. L’Homme. L’Homme. Essai
Essai zoologique sur zoologique sur le genre
le genre humaine. humaine. París
Paris
61 clasiflcación de clasificación de Ulloa,
Ulloa, que visto un que visto un indio
indio estaban estaban
62 llarmarse siboneyes, llamarse siboneyes,
haytianos, haytianos,
jamaiquinos y jamaiquinosboriqueños,
boriqueños, por que por que en el trascurso
en el trascurso del del tiempo
tiempo
63 caracteres especia es caracteres especiales
sostenidos y se sostenidos y se origina
origina la subraza la subraza
63 á ser dos razas á ser dos razas
fundament les y una fundamentales y una
tercera por tercera por
63 Todo e to es la Todo esto es la
influencia del medio influencia del medio
ambiente, con ambiente, con
65 en su Systemes of en su Systems of
Consanguinity and Consanguinity and
Affinity of the Affinity of the Human
Human Family, Family, sostiene la
sostiene la unidad unidad
70 en combatir y hacer en combatir y hacer
frente. Los indios frente. Los indios serían
seraín unos unos
70 españolas, seis de á españoles, seis de á
caballo y cien de á caballo y cien de á pie.
pie. La caballería La caballería
71 de igual modo que lo de igual modo que lo
hacían los indo hacían los indo-
antillanos antillanos
81 de S. A. Los Caribes de S. M. Los Caribes se
se los comen é los comen é hácenles
hácenles
82 rescibir á su recibir á su
conversasión á los conversasión á los
chrystianos, ni á los chrystianos, ni á los
predicadores predicadores
82 del dicho Golfo, está del dicho Golfo, está
otra provincia, que otra provincia, que se
se dise de los Oleros, dice de los Oleros, los
los quales quales
83 de más arriba hasta de más arriba hasta lo
lo demás abajo, que de más abajo, que no
no son declaradas son declaradas por de
por de
83 las dichas tierras é las dichas tierras é
provincias, guerra, provincias, guerra, ni
ni fuerza, ni fuerza, ni violencias, ni
violencias, ni extorsiones;
extorciones,
84 un sin número de un sinnúmero de
pueblos indígenas pueblos indígenas con
con distintas distintas
84 Archivos de Indias. Archivo de Indias. Doc.
Doc. inéd inéd
88 sobresalir. La sobresalir. La quijada es
quijada es antropológicamente
antropológimente ortognática [vertical]
ortognática mesognática [media] ó
[vertical]
mesognática [media]
ó
94 ni mucho menos; ni mucho menos; pero,
pero, si expresiones sí expresiones de
de aprecio aprecio
97 de Uravoán estaba de Urayoán estaba
junto al Guaorabo, junto al Guaorabo, en
en Yagüeca Yagüeca
97 la de Avmamón en la de Aymamón en las
las riberas del riberas del Coalibina
Coalibina
104 En ellos tendrián En ellos tendrían
también los también los caciques,
caciques, bohiques bohiques
106 magiiey, se le ha magüey, se le ha
agregado el agregado el retumbante
retumbante cuero cuero
107 Estrañará á alguno, Estrañará á algunos,
que hayamos que hayamos concedido
concedido
113 ofrendas. La ofrendas. La explicación
explicación de ésto de esto es bien sencilla:
es bien sencilla: el el
113 V. Durny. Ob. cit. V. Duruy. Ob. cit.
117 (Fitolatría) á la (Fitolatría) á la
bienhechora y bienhechora y
mistoriosa planta misteriosa planta
125 Pedro Mártir de Pedro Mártir de
Anglería. 1ª decada, Anglería. 1ª década, lib.
lib. IX., cap. IV. IX., cap. IV.
126 Para los indo- Para los indo-antillanos
antillanos no todo no todo terminaba
terrminaba
127 de continuo y ruje y de continuo y ruge y se
se encrespa, y los encrespa, y los ríos
ríos desde la desde la
131 por el ontrario, de por el contrario, de
peces en los ríos y peces en los ríos y
ensenadas ensenadas
139 están trabajadas están trabajadas
ligeramente ligeramente oblicuas;
oblícuas; pero con pero con una
una
147 fermentación, fermentación, habían de
habían de producirse
producirse necesariamente
necesamente
147 Puso Colón Puso Colón Fernandina
Fernandina á la isla á la isla que los indios
que los indios llamaban Yumaí
llamaban Yumai
148 entre ellos, según entre ellos, según como
como están más están más cerca ó
cercas ó
148 Lestrigones y los Lestrigones y los
Ciclopes. Y Ciclopes. Y Herodoto
Herodoto nos nos refiere, que fueron
refiere, que fueron canibales los Scitas,
canibales los Scitas, Germanos, Celtas,
Germanos, Celtas, Fenicios, Tártaros y
Fenicios, Tártaros y Etíopes. El hambre es
Etiopes. El hambre mala
es mal
148 los Scitas, los Scitas, Germanos,
Germanos, Celtas, Celtas, Fenicios,
Fenicios, Tártaros y Tártaros y Etíopes. El
Etiopes. El hambre hambre es mala
es mal consejera. No consejera. No
148 que tiene de extraño ¿qué tiene de extraño
que en la atrasada que en la atrasada
época de la bestia época de la bestia
humana lo fuéramos humana lo fuéramos
materialmente. materialmente?
150 de la Dominique de la Dominique «que
«que lors de la lors de la conquête des
conquête des êles, le eles, le chef caraibe
chef caraibe avait avait exterminé tous les
exterminé tous les
151 debemos la Avmara. debemos la Aymara. A
A los misioneros los misioneros Vega,
Vega, Valdivia Valdivia
151 Joseph de Anchieta. Joseph de Anchieta.—
—Arte de Arte de Grammatica da
Grammatica da lingua mais usada na
lingua mais usada costa do Brasil
nacosta do Brasil
152 que nosotos que nosotros
afirmamos, afirmamos,
apoyándonos en el apoyándonos en el
estudio estudio
152 mallorquín y él mallorquín y él dialecto
dialecto catalán, catalán, proceden de la
proceden de la lenua lengua
153 que caney procede que caney procede de
cana; maíz se origina cana; maíz se origina en
en mahizo mahizo
153 relación ó estracto relación ó extracto de
de una carta que una carta que escribió el
escribió el
158 los caños del Delta y los caños del Delta y en
en su desagiie en el su desagüe en el mar,
mar, en en
160 del escritor que lo del escritor que lo
anota, sufre también anota, sufre también
cierta variente cierta variante
166 El lenguaje indo El lenguaje indo-
antillano, por lo antillano, por lo poco
poco que que conservamos
conservamos
167 ésto lo hemos esto lo hemos
recopilado con recopilado con paciente
paciente labor. No labor. No
167 sabána, llano; ji, por sabana, llano; ji, por ní,
ní, agua; bo por abo, agua; bo por abo, lugar.
lugar. He aquí un He aquí un lugar llano
lugar llano con agua. con agua. Como si di
Como si di dijéramos: Buen sitio de
dijeramos: Buen labranza. Una de las
sitio de labranza. ideas principales del
Una de las ideas boriqueño era buscar en
principales del la isla buenos sitios
boriqueño era donde sembrar sus
buscar en la isla yucubías y sus ajes y
buenos sitios donde batatas. Así como elegir
sembrar sus
yucubías y sus ajes y
batatas. Así como
elejir
173 Espíritu benéfico.— Espíritu benéfico.—
Yukivu; Haytí, Yukiyu; Haytí, Yukajú;
Yukajú; Ci. Ci.
175 Generoso.—Matum. Generoso.—Matún
175 nim; Dk. tanka; DD. nim; Dk. tanka; DD.
tcho; Nabajo tcho; Navajo (apaches)
(apaches) cha cha
175 Hilo para canastos. Hilo para canastos.—
—Biiao. Bijao
187 que Montes de Oca que Montes de Oca
traduce padre, traduce padre,
adaptándo adaptando
187 Nosotros, siguiendo Nosotros, siguiendo á
á Lucien Adam, Lucien Adam,
traduciriamos traduciríamos
187 Lucien Adam. Lucien Adam.
Matériaux pour Matériaux pour servir à
servir á l’établissement d’une
l’établissement d’ grammaire comparée
une grammaire
comparée
189 Ki-umú-e titanvem Ki-umú-e titanyem
ubécuvum, santiket ubécuyum, santiket ála
ála evéti.—Nuestro eyéti.—Nuestro
190 dóminical en tupí- dominical en tupí-
guaraní, guaraní, sometiéndola á
sometiéndola á algunas
algunas
197 que nabos que nabos
comunmente.” El comunmente.” El
mismoa utor, en el mismo autor, en el
199 aves llamaban los aves llamaban los
españoles españoles alcatraces.”
alcatraces.” En árabe En arabe
199 para componer para componer areytos
arevtos ó ritmos.” ó ritmos.” Por orden de
Por orden de
202 dos primeras dos primeras palabras
palabras llevan llevan radicales indo-
radicales indo- antillanos
antillanas
203 Ateque.—Arbol de Ateque.—Arbol de
Cuba. (Cordia callo Cuba. (Cordia
cocca). callococca).
203 que el aborígen la que el aborigen la
cultivara. Oviedo cultivara. Oviedo (lib.
(lib. VII VII
203 pepo) con la pepo) con la candungo
candungo ó ó marimbo (cucurbita
marimbo (cucurbita lagenaria
lagenaira
203 (crecentia cujete). (crescentia cujete).
Probablemente, Probablemente,
después de después de importada
importada
207 se denomina punta se denomina punta
Maisí. Las Casas Maisí. Las Casas anota
anota Bavatiquiri. Bayatiquiri. Corrupción
Corrupción de de Bayatikeri.
Bavatikeri.
208 Bajaraque.—El Bajareque.—El bohío
bohío que tenía que tenía mucha
mucha extensión extensión
214 Terræ Novœ; y así Terræ Novæ; y así
aparece en las obras aparece en las obras de
de Oviedo Oviedo
219 buena como de lino, buena como de lino, é
é ésta llaman ésta llaman cabuya, la
cabuva, la penúltima penúltima
219 la voz cabuva viene la voz cabuya viene de
de cabo cabo
221 Hay también el Hay también el
Chrvsophvllum Chrysophyllum
oliviforme oliviforme
222 Caiaguala.—Vegetal Calaguala.—Vegetal
silvestre. Es el silvestre. Es el polipodio
polipodio
222 y el Presbítero Ponce y el Presbítero Ponce de
de León anotaron León anotaron Camuy
Camuv
222 tomando la e par tomando la e por una s,
una s, han hecho el han hecho el vocablo
vocablo
226 padre Nazario (Ob. padre Nazario (Ob. cit.)
cit.) á seguirles en á seguirles en esta
esta equivocacion equivocación
226 Sir Walter Ralegh, Sir Walter Raleigh,
desde la isla de desde la isla de Trinidad
Trinidad hasta hasta
229 Ciales.—No es Ciales.—No es palabra
palabra indígena. indígena. Nombre de un
Nombre de nu
234 cuyo monotono grito cuyo monótono grito
nocturno es coquí, nocturno es coquí,
coquí coquí
234 este cú ó kú de la este cú ó kú del radical
radical tu; pues tu- tu; pues tu-rey, era
rey, era
234 Cuaia.—Río de Santo Cuaja.—Río de Santo
Domingo, tributario Domingo, tributario del
del
236 El nombre indígena El nombre indígena era
era cabuva cabuya
237 Daiabón.—Lugar del Dajabón.—Lugar del
cacicazgo de Marien. cacicazgo de Marien.
Las Las
250 Guaraca del Guaraca del Guayaney,
Guavaney, y por y por último se quedó
último se quedó con con
251 Guavabacán.— Guayabacán.—Arbol.
Arbol. (Myrica (Myrica divaricata)
divaricata)
255 Haití.—Véase Havtí Haití.—Véase Haytí
262 su régulo Boiekio. su régulo Bojekio.
Comprendía á Comprendía á
Hanigagía, Yaquino Hanigagía, Yaquino
262 de los sucesos de la de los sucesos de la
conquista de la conquista de la Nueva
Nueva Espana España
265 haze el abrigo una haze el abrigo una
ysleta que tendrá de ysleta que tendrá de
amplido tres amplio tres
272 Manaca.—La palma Manaca.—La palma
real. (Oreodoxia real. (Oreodoxa regia)
regia)
274 Leónen Puerto Rico, León en Puerto Rico,
cuando visitó, la isla cuando visitó, la isla en
en 1508 1508
278 también esplica esta también explica esta
frase que hemos frase que hemos citado
citado
279 Nibajo.—Río Nibajo.—Río
dominican tributario dominicano tributario
del Yaque. del Yaque.
280 O.—Radical indo- O.—Radical indo-
antillana. Montaña antillano. Montaña
287 Semí.—La divinidad Semí.—La divinidad
tutelar del indo- tutelar del indo-
anttillano antillano
all Pedro Mártir (Dec. Pedro Mártir (Déc.

1. Errores tipográficos palpables corregidos


silenciosamente; retuvo ortografía y dialecto no
estándar.
2. Notas a pie de página reindexadas utilizando números y
recopiladas al final del último capítulo.
*** END OF THE PROJECT GUTENBERG EBOOK PREHISTORIA
DE PUERTO-RICO ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree to
abide by all the terms of this agreement, you must cease using
and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project
Gutenberg™ works in compliance with the terms of this
agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms
of this agreement by keeping this work in the same format with
its attached full Project Gutenberg™ License when you share it
without charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it
away or re-use it under the terms of the Project Gutenberg
License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country where
you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of the
copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must, at
no additional cost, fee or expense to the user, provide a copy, a
means of exporting a copy, or a means of obtaining a copy upon
request, of the work in its original “Plain Vanilla ASCII” or other
form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other

You might also like