Upload
itnig
View
583
Download
1
Embed Size (px)
DESCRIPTION
In the Friday training I am going to introduce CouchBase Server, a NoSQL (Not only SQL, document oriented) database and outline differences to Apache CouchDB. We're going through a quick setup of the CouchBase Server and the basics of CouchDB document design. I will show some real world examples, followed by a discussion. Who is Patrick Heneise? Patrick is the Founder & CEO of desentia. He achieved a MSc in Media Technology and BSc in Computer Science in Media. Ever since he has improved social interaction and media with creative and professional technology solutions. He started his first business in 2006 during his studies in the fields of eLearning and web technologies and worked for various companies and universities in eCommerce, telecommunications and research & development.
Citation preview
GETTING COMFORTABLE WITH
Patrick Heneise, @PatrickHeneise
About.Me/PatrickHeneiseInformation Architect / Consultant
MSc. in Media Technology, Leiden University, NL
BSc. in Computer Science in Media, Furtwangen University, DE
Certified Software Engineer
♥node.js, , NoSQL
2 years CouchDB/Couchbase experience
AGENDA
Agenda
Introduction to Couchbase
Introduction to Document Design and Best Practices
Introduction to Views (Map, Reduce)
Introduction to memcached
Use Cases
Q&A
Not on the Agenda
Cluster Design
Deployment
Security
Advanced Document Design
Buckets/vBuckets
Couchbase ServerCouchDB
JSON Documents
Indexing and Querying
Map/Reduce
memcached
In-memory key-value store
Sub-millisecond latency
Distributed
Couchbase Server
Auto-Sharding (dynamically add new servers)
Management and monitoring
Data replication with auto-failover
Mobile synchronization
WHY NOSQL?
Why NoSQL?
No schema required
Interactive database engineering
Organic growth
Document/Object related
CouchDB
Use Cases
Information storage
Catalogues
Document-based information
How does it look like?{
“title”: “Barcelona”,“state”: “Catalonia”,“tagline”: “Best place to live in Europe”,“population”: 1621537,“tags”: [
“gaudi”, “sagrada familia”, “beach”, “sun”],“startups”: {
“itnig”: {“tagline”: “Make it happen”,“tags”: [“web development”, “marketing”]
},“desentia”: {
“tagline”: “design to go.”,“tags”: [“design”, “mobile”, “commerce”]
}}
}
Strings
Key Value
NumbersArrays
ObjectsNested Objects
How to interact with data?city.title
city.tags
city.tags[4]
city.startups.desentia.tagline
“Barcelona”
[“gaudi”, “sagrada familia”, “beach”, “sun”]
“gaudi”
“design to go.”
=>
=>
=>
=>
Where’s SELECT?
Map/Reduce Views
JavaScript or Erlang
Spatial Views
Views
function (doc, meta) {
if(doc.jsonType == 'city') {
emit(doc.title, doc.tagline);
}
}
-{- total_rows: 3,- rows:
[-
{- id: "barcelona",- key: "Barcelona",- value: "Best place to live in Europe"
- },-
{- id: "berlin",- key: "Berlin",- value: "Beer and Startups"
- },-
{- id: "london",- key: "London",- value: "Bloody Rainy"
- }- ]
-}
View all tagsfunction (doc, meta) {
if(doc.jsonType == 'city') {
doc.tags.forEach(function(tag) {
emit(tag, doc.title);
});
}
}
-{- total_rows: 12,- rows:
[-
{- id: "barcelona",- key: "beach",- value: "Barcelona"
- },-
{- id: "berlin",- key: "brandenburg gate",- value: "Berlin"
- },-
{- id: "berlin",- key: "cold",- value: "Berlin"
- },-
{- id: "berlin",- key: "DDR",- value: "Berlin"
- },...
JOINSfunction (doc, meta) {
if(doc.jsonType == "startup") {
emit([doc.city, 1], doc.title);
} else if(doc.jsonType == "city") {
emit([meta.id, 0], doc.title);
}
}
["barcelona",0] barcelona "Barcelona"["barcelona",1] desentia "desentia"["barcelona",1] itnig "itnig"["berlin",0] berlin "Berlin"["berlin",1] soundcloud "soundcloud"["london",0] london "London"
MAP/REDUCEfunction (doc, meta) {
if(doc.jsonType == "startup") {
emit(doc.city, 1);
}
}
_count
-{- rows:
[-
{- key: "barcelona",- value: 2
- },-
{- key: "berlin",- value: 1
- }- ]
-}
-{- rows:
[-
{- key: null,- value: 3
- }- ]
-}
group_level 0 group_level 1
memcached
Use Cases
Session Store
Always and fast changing data (user activity)
Stock exchange data
Game states
Pure key-value store
c.set("foo", 1)c.incr("foo") #=> 2c.incr("foo", :delta => 2) #=> 4c.incr("foo", 4) #=> 8c.incr("foo", -1) #=> 7
c.set("foo", "bar")c.set("foo", "bar", :ttl => 30)c["foo"] = "bar"
Examples
user:patrick:id => 1
user:patrick:lastPage => ‘/account’
farmhill:currentPlants => 5
farmhill:nextAvailablePlant => ‘Sunflower’
sess:abc:username => ‘patrick’
global:nextUserId => 15
DEMO
WHERE CAN I USE COUCHBASE?
Use CaseseCommerce Systems
Products, Session, Users, Sales, ...
Q/A Systems
Store a document per user with questions and answers
History Databases
Ancient Books, letters, transcriptions, ...
mCommerce Systems
Products, Location Information
Social Information Systems / Business Intranets
Timesheets, Project information
Wiki / CMS / Blog
Articles, Pages, ...
Gaming Systems
Game states, user data
...
Additional Information
couchbase.com / @couchbase / @jchris / @janl
couchbasemodels.com / @scalabl3
couchbase.com/docs/couchbase-manual-2.0/
couchbase.com/couchconf-berlin - CouchConf Berlin, Oct 30
Q&A
JOIN US ON MEETUP:THE-BARCELONA-COUCHBASE-GROUP
THANK YOU!