The document outlines an agenda for a workshop on ArangoDB and Ashikawa. The agenda includes introducing ArangoDB, installing it, performing CRUD operations, using the query language, and building a small example with the Ruby driver Ashikawa. It also provides information on importing data and performing queries on ArangoDB.
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Rupy2012 ArangoDB Workshop Part1
1. ArangoDB & Ashikawa
Workshop
Frank Celler & Lucas Dohmen, triAGENS, Cologne
RuPy 2012, Brno
2012-11-16
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
2. Agenda
Brief Introduction to ArangoDB
Installing ArangoDB
CRUD Operations for Documents
ArangoDB Query Language
Using the Ruby Driver Ashikawa
Build a small Ruby example
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
3. multi-model NoSQL database and application
server
Basically, it's a document store...
...but also supports key / value access
... and provides functionality to store and analyse
document relations, making it a graph database,
too
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
4. arangod: the server, written in C++
arangosh: JavaScript shell
arangoimp: Import for JSON / CSV
Ashikawa: Ruby driver
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
5. Mac OS X
brew install arangodb installs stable 1.0.4
brew install --devel arangodb installs development 1.1.beta2
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/arangodb/1.0.4/homebrew.mxcl.arangodb.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.arangodb.plist
If this is an upgrade and you already have the homebrew.mxcl.arangodb.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.arangodb.plist
cp /usr/local/Cellar/arangodb/1.0.4/homebrew.mxcl.arangodb.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.arangodb.plist
To start the ArangoDB server manually, run:
/usr/local/sbin/arangod
To start the ArangoDB shell, run:
arangosh
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
6. Download a Package
Use http://www.arangodb.org/download to download a package for
Centos
Debian
Ubuntu
SuSE
Mint
Mac OS X
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
12. List & Sub-Objects
arangosh> r = db.cars.save({ model: "yeti",
address: { city: "Cologne", street: "Trankgasse" },
drivers: [ "fceller", "lucas" ]});
arangosh> car = db.cars.document(r);
{
model : "yeti",
address : {
city : "Cologne",
street : "Trankgasse"
},
drivers : [
"fceller",
"lucas"
],
_id : "2769319/6504871",
_rev : 6504871
}
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
13. Import Data
~> curl "http:/ /www.arangodb.org/rupy2012/airports.csv" > airports.csv
~> head -2 airports.csv
"id","ident","type","name","latitude_deg","longitude_deg","elevation_ft","continent",...
6523,"00A","heliport","Total Rf Heliport",40.07080078125,-74.9336013793945,11,"NA",....
~> curl "http://www.arangodb.org/rupy2012/names_10000.json" > names_10000.json
~> head -2 names_10000.json
{"name":{"first":"Caren","last":"Ferm"},"gender":"female","birthday":"1971-07-22","contact":{"address":{"street":"3
Wyoming Cir","zip":"08053","city":"Marlton","state":"NJ"},"email":["caren.ferm@nosql-matters.org","ferm@nosql-
matters.org","caren@nosql-matters.org"],"region":"856","phone":["856-5374929"]},"likes":
["boxing"],"memberSince":"2008-11-07"}
{"name":{"first":"Jack","last":"Irias"},"gender":"male","birthday":"1967-02-20","contact":{"address":{"street":"7
Santa fe Way","zip":"19885","city":"Wilmington","state":"DE"},"email":["jack.irias@nosql-matters.org","irias@nosql-
matters.org","jack@nosql-matters.org"],"region":"302","phone":[]},"likes":
["snowboarding"],"memberSince":"2009-04-27"}
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
14. Import Data
~> /usr/local/bin/arangoimp --type json --collection users --create-collection true names_10000.json
Connected to Arango DB 127.0.0.1:8529 Version 1.0.4
----------------------------------------
collection : users
create : yes
reusing ids : no
file : names_10000.json
type : json
quote : "
separator : ,
connect timeout : 5
request timeout : 300
----------------------------------------
Starting JSON import...
created : 10000
errors : 0
total : 10000
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
15. Import Data
~> /usr/local/bin/arangoimp --type csv --collection airports --create-collection true airports.csv
Connected to Arango DB 127.0.0.1:8529 Version 1.0.4
----------------------------------------
collection : airports
create : yes
reusing ids : no
file : airports.csv
type : csv
quote : "
separator : ,
connect timeout : 5
request timeout : 300
----------------------------------------
Starting CSV import...
created : 43991
errors : 0
total : 43992
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
16. Query Data
Grep 5 users and return their names and ids
FOR u IN users
LIMIT 5
RETURN u
arangosh> a = db._createStatement(
{ query: "for u in users limit 5 return u" }).execute()
[object ArangoQueryCursor]
arangosh> a.next()
{ _id : "6570407/264716711", _rev : 264716711, gender : "male", birthday :
"1964-01-09", memberSince : "2008-09-18", name : { last : "Geving", first :
"Millard" }, contact : { region : "409", phone : ["409-0605391"], address : { zip :
"75941", city : "Diboll", state : "TX", street : "18 Woodlawn Loop" }, email :
["millard.geving@nosql-matters.org", "geving@nosql-matters.org", "millard@nosql-
matters.org"] }, likes : ["shopping", "skiing"] }
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
17. Query Data
Find out how many users live in each city
FOR u IN users
COLLECT city = u.contact.address.city INTO g
LIMIT 0,20
RETURN { "city" : city, "users" : length(g) }
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
18. Query Data
Find the 5 regions in state CA with the most inhabitants
FOR u IN users
FILTER u.contact.address.state == "CA"
COLLECT region = u.contact.region INTO group
SORT LENGTH(group) DESC
LIMIT 0, 5
RETURN { "region" : region, "count" : LENGTH(group) }
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
19. Query Data
Find the other top 5 hobbies of male users that also like running
FOR likes IN (
FOR u IN users
FILTER u.gender == "male" && "running" IN u.likes
FOR value IN u.likes
FILTER value != "running"
RETURN value
)
COLLECT what = likes INTO group
SORT LENGTH(group) DESC
LIMIT 0, 5
RETURN { "what" : what, "count" : LENGTH(group) }
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
20. Query Data
Find the 10 nearest larger airports around Cologne
FOR a IN NEAR(airports, 50.67, 6.9, 200, "distance")
FILTER a.type == "large_airport"
SORT a.distance ASC
LIMIT 0, 10
RETURN { "name" : a.name,
"code" : a.iata_code,
"country" : a.iso_country,
"city" : a.municipality,
"distance" : CONCAT(TO_STRING(CEIL(a.distance/1000)), ' km') }
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12
22. Thank You!
Stay in Touch:
Fork me on github
Google Group: ArangoDB
Twitter: @fceller & @arangodb
www.arangodb.org
www.arangodb.org (c) f.celler@triagens.de
Donnerstag, 15. November 12