SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
NoSQL and CouchDB
The view from MOO
Who is Steve Storey?

• Hobby Coder for ~20 years
  Everything from Spectrum 48k through x86 assembler

• Professional Coder for 12 years
  Everything from Pascal + REXX up to Java + PHP

• Application Architect at MOO
  Everything from coding to meetings
Who are MOO?

• MOO is a London based, online printing company

• Launched in 2006 with one product – The MiniCard

• Expanded to 5 products

• Now has a UK and US printing/shipping facility

• We ship globally – to over 43 countries in our first year
  Now well over 100, including Antarctica
MOO Technology Stack


• Debian Lenny platform



• LAMP stack



• PHP 5.2
Where's the NoSQL?




    <This slide intentionally left blank>




        But who can tell what the future holds?
What is NoSQL?

• Mostly an inflammatory descriptive term

• Refers to a database of semi-structured data
  “semi-structured” defined however you like it
  “database” might or might not have in-built query capability
  not “relational” as per RDBMS, but might allow arbitrary relationships between
  data nodes

• 4 general types
  Key/Value – simple arbitrary data store (unstructured)
  Graph databases – Inspired by Euler + graph theory
  BigTable – clones of Google's BigTable database
  Document – essentially associative arrays
What is NoSQL NOT?

• A new idea

• A replacement for SQL
 NoSQL = “Not Only SQL” ?
 Entirely complementary to RDBMS systems

• Non-transactional
 This does slightly depend on your definition of transactional
Quick List of popular implementations

• Apache CouchDB

• MongoDB

• Amazon Dynamo
  Powers the Amazon S3 web service

• Memcached

• Neo4J

• More at http://en.wikipedia.org/wiki/Structured_storage
Quick List of less popular implementations

• Lotus Notes/Domino
 In fact – very popular with corporates, just not their employees
 1.0 released in 1989
 One of its engineers was Damian Katz who later went on to write CouchDB
What is CouchDB?

• Document store
  A document is an associative array (in fact a JSON associative array)

• Allows developer-defined views on the documents
  Akin to materialised views found in Oracle
  Views use a Map/Reduce engine

• Restful HTTP interface
  Client APIs written for most higher level languages
  Also means that you can host an AJAX app entirely in CouchDB

• Built-in fault tolerant replication
  NOTE! Not clustering
  “Eventually consistent”
  Lock-less updates (Multi-version concurrency control)
Why do I need documents?

• How much data is document like?
  Wiki's
  Blogs
  SQL tables with CLOB fields (text/mediumtext/longtext)

• Schema-less
  Arbitrary fields can be added at any point to any document
  The DB doesn't attach any significance to (almost) any field
  “_id” and “_rev” are special

• Hierarchical data structures
  moo.com Pack data model
Woah! No schema?

• Requires thinking a bit differently
  Field usage is defined by the code
  Less restrictive in reality since different fields can be used for different concerns
  No type or null restrictions (but documents can be validated at save time)
  A document should represent the complete state of that part of the data model

• Doesn't necessarily mean acting very differently
  Does all your code definitely attaches the same meaning to all the DB fields?
  Even the meaning of status flags?
  How long does it take to add a new column to a MySQL DB?
  How much time do developers take learning your ORM solution?
  How much time is spent mapping objects and relationships to tables, only to
  load the complete tree on every request?
  What happens to the careful DB guarantees if you shard your data?
Simple Views

• Matches a set of documents on some condition
  the WHERE clause
  also the FROM clause

• Outputs a set of fields, or parts of the associative array
  the SELECT clause

• Usually coded in Javascript
  CouchDB does however support alternative view server
  View servers for Python, PHP, Ruby, Erlang, Perl available

• Uses only the “map” part of map/reduce

• No joins
  But the documents represent the full state of that part of the data model ... right?
Advanced Views

• Still no joins

• Can perform complex calculations
  You can only rely on the content of the document being processed
  But the documents represent the full state of that part of the data model ... right?

• A Reduce function can be used to aggregate calculations

• Map and reduce intermediate results are indexed
  Once calculated for a document, they never need to be re-calculated until the
  document is updated
  It's therefore very fast!

• Not as obvious how to program them
What about transactions?

• ACID compliant
  On a document-by-document basis
  Tolerant of very wide array of failure modes due to Erlang paradigms
  The documented way to cleanly stop a CouchDB server is to kill the process

• No user-defined transactions
  Essentially it's auto-commit
  But the documents represent the full state of that part of the data model ... right?
  No isolation levels, so don't run your banking on it …
  No isolation levels to get in the way when you're storing data for a single user
  Effective isolation is READ_COMMITTED

• No distributed transactions
  The world is eventually consistent
  A given user tied to a particular CouchDB server will always have a consistent
  world view
Scaling

• Master/master replication strategy

• Eventually consistent replication
  But the documents represent the full state of that part of the data model ... right?

• Requires conflict resolution in the application code
  This might as simple as last update wins
  Can equally be a user-driven process – the application code sees all conflicts of
  a document and can decide how to proceed

• Offline working is easy
  In fact – in-built for AJAX applications hosted within the CouchDB database
Weaknesses

• DBs require periodic compaction
  All document operations (including deletion) are appended to the DB file

• Under heavy update load, storage may be sub-optimal
  Try MongoDB, which does in-place updates – but requires greater transactional
  overhead as a result

• SQL skills don't map (or reduce) over to CouchDB
The known unknowns
What's been left out


• Security
  Recently introduced in 0.11.0
  Pluggable authentication, defaults to CouchDB hosted _users database
  Together with the validation functionality fairly powerful

• Caveat emptor ...
  There's more to the details of everything I've talked about
Concluding ...

• What's MOO doing with all this?

• NoSQL databases have their place
  There's more to the details of everything I've talked about

• SQL can do everything NoSQL can
  Might take rather longer to do it
  NoSQL is better suited for some use-cases

• Many different implementations for different use-cases
  Each as their own strengths and weaknesses

• Download and try a few!
Questions?

• Steve Storey - steves@moo.com

• CouchDB - http://couchdb.apache.org/
• Further reading - http://books.couchdb.org/relax/

Mais conteúdo relacionado

Mais procurados

Lessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBLessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBOren Eini
 
Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Databasezingopen
 
Kafka is simple, it is just an infinite file
Kafka is simple, it is just an infinite fileKafka is simple, it is just an infinite file
Kafka is simple, it is just an infinite fileGabrielMironBrezai
 
NoSQL Database in .NET Apps
NoSQL Database in .NET AppsNoSQL Database in .NET Apps
NoSQL Database in .NET AppsShiju Varghese
 
A Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-ServiceA Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-ServiceValeri Karpov
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Serverswebhostingguy
 
Infinspan: In-memory data grid meets NoSQL
Infinspan: In-memory data grid meets NoSQLInfinspan: In-memory data grid meets NoSQL
Infinspan: In-memory data grid meets NoSQLManik Surtani
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoSencha
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack DiscussionZaiyang Li
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-SideASIMYILDIZ
 
What is a good technology stack today?
What is a good technology stack today?What is a good technology stack today?
What is a good technology stack today?Netlight Consulting
 
Why we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseWhy we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseAndreas Jung
 

Mais procurados (20)

Lessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBLessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDB
 
Zing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value DatabaseZing Database – Distributed Key-Value Database
Zing Database – Distributed Key-Value Database
 
Kafka is simple, it is just an infinite file
Kafka is simple, it is just an infinite fileKafka is simple, it is just an infinite file
Kafka is simple, it is just an infinite file
 
NoSQL Database in .NET Apps
NoSQL Database in .NET AppsNoSQL Database in .NET Apps
NoSQL Database in .NET Apps
 
A Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-ServiceA Gentle Introduction to Functions-as-a-Service
A Gentle Introduction to Functions-as-a-Service
 
WebDev Crash Course
WebDev Crash CourseWebDev Crash Course
WebDev Crash Course
 
Client server
Client serverClient server
Client server
 
Why ruby and rails
Why ruby and railsWhy ruby and rails
Why ruby and rails
 
Beyond Apache: Faster Web Servers
Beyond Apache: Faster Web ServersBeyond Apache: Faster Web Servers
Beyond Apache: Faster Web Servers
 
In Memory Cahce Structure
In Memory Cahce StructureIn Memory Cahce Structure
In Memory Cahce Structure
 
SPA vs. MPA
SPA vs. MPASPA vs. MPA
SPA vs. MPA
 
Infinspan: In-memory data grid meets NoSQL
Infinspan: In-memory data grid meets NoSQLInfinspan: In-memory data grid meets NoSQL
Infinspan: In-memory data grid meets NoSQL
 
Revision
RevisionRevision
Revision
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
 
Javascript on Server-Side
Javascript on Server-SideJavascript on Server-Side
Javascript on Server-Side
 
D2RQ
D2RQD2RQ
D2RQ
 
What is a good technology stack today?
What is a good technology stack today?What is a good technology stack today?
What is a good technology stack today?
 
Why we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseWhy we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL Database
 

Semelhante a NoSQL and CouchDB: the view from MOO

MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring dataJimmy Ray
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesKyle Banerjee
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Don Demcsak
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodbMohammed Ragab
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQLbalwinders
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]Huy Do
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDBMongoDB
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Lucas Jellema
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityBill Buchan
 
Introduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and KubernetesIntroduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and KubernetesDavid Charles
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQLRTigger
 

Semelhante a NoSQL and CouchDB: the view from MOO (20)

MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
Database Technologies
Database TechnologiesDatabase Technologies
Database Technologies
 
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL DatabasesDropping ACID: Wrapping Your Mind Around NoSQL Databases
Dropping ACID: Wrapping Your Mind Around NoSQL Databases
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
NoSQL and MongoDB
NoSQL and MongoDBNoSQL and MongoDB
NoSQL and MongoDB
 
Spring in the Cloud
Spring in the CloudSpring in the Cloud
Spring in the Cloud
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]NoSQL for great good [hanoi.rb talk]
NoSQL for great good [hanoi.rb talk]
 
When to Use MongoDB
When to Use MongoDBWhen to Use MongoDB
When to Use MongoDB
 
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
Introducing NoSQL and MongoDB to complement Relational Databases (AMIS SIG 14...
 
Meteor + React
Meteor + ReactMeteor + React
Meteor + React
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database Connectivity
 
ORM Methodology
ORM MethodologyORM Methodology
ORM Methodology
 
Introduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and KubernetesIntroduction to Microservices with Docker and Kubernetes
Introduction to Microservices with Docker and Kubernetes
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
 
CDC to the Max!
CDC to the Max!CDC to the Max!
CDC to the Max!
 

Último

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

NoSQL and CouchDB: the view from MOO

  • 1. NoSQL and CouchDB The view from MOO
  • 2. Who is Steve Storey? • Hobby Coder for ~20 years Everything from Spectrum 48k through x86 assembler • Professional Coder for 12 years Everything from Pascal + REXX up to Java + PHP • Application Architect at MOO Everything from coding to meetings
  • 3. Who are MOO? • MOO is a London based, online printing company • Launched in 2006 with one product – The MiniCard • Expanded to 5 products • Now has a UK and US printing/shipping facility • We ship globally – to over 43 countries in our first year Now well over 100, including Antarctica
  • 4. MOO Technology Stack • Debian Lenny platform • LAMP stack • PHP 5.2
  • 5. Where's the NoSQL? <This slide intentionally left blank> But who can tell what the future holds?
  • 6. What is NoSQL? • Mostly an inflammatory descriptive term • Refers to a database of semi-structured data “semi-structured” defined however you like it “database” might or might not have in-built query capability not “relational” as per RDBMS, but might allow arbitrary relationships between data nodes • 4 general types Key/Value – simple arbitrary data store (unstructured) Graph databases – Inspired by Euler + graph theory BigTable – clones of Google's BigTable database Document – essentially associative arrays
  • 7. What is NoSQL NOT? • A new idea • A replacement for SQL NoSQL = “Not Only SQL” ? Entirely complementary to RDBMS systems • Non-transactional This does slightly depend on your definition of transactional
  • 8. Quick List of popular implementations • Apache CouchDB • MongoDB • Amazon Dynamo Powers the Amazon S3 web service • Memcached • Neo4J • More at http://en.wikipedia.org/wiki/Structured_storage
  • 9. Quick List of less popular implementations • Lotus Notes/Domino In fact – very popular with corporates, just not their employees 1.0 released in 1989 One of its engineers was Damian Katz who later went on to write CouchDB
  • 10. What is CouchDB? • Document store A document is an associative array (in fact a JSON associative array) • Allows developer-defined views on the documents Akin to materialised views found in Oracle Views use a Map/Reduce engine • Restful HTTP interface Client APIs written for most higher level languages Also means that you can host an AJAX app entirely in CouchDB • Built-in fault tolerant replication NOTE! Not clustering “Eventually consistent” Lock-less updates (Multi-version concurrency control)
  • 11. Why do I need documents? • How much data is document like? Wiki's Blogs SQL tables with CLOB fields (text/mediumtext/longtext) • Schema-less Arbitrary fields can be added at any point to any document The DB doesn't attach any significance to (almost) any field “_id” and “_rev” are special • Hierarchical data structures moo.com Pack data model
  • 12. Woah! No schema? • Requires thinking a bit differently Field usage is defined by the code Less restrictive in reality since different fields can be used for different concerns No type or null restrictions (but documents can be validated at save time) A document should represent the complete state of that part of the data model • Doesn't necessarily mean acting very differently Does all your code definitely attaches the same meaning to all the DB fields? Even the meaning of status flags? How long does it take to add a new column to a MySQL DB? How much time do developers take learning your ORM solution? How much time is spent mapping objects and relationships to tables, only to load the complete tree on every request? What happens to the careful DB guarantees if you shard your data?
  • 13. Simple Views • Matches a set of documents on some condition the WHERE clause also the FROM clause • Outputs a set of fields, or parts of the associative array the SELECT clause • Usually coded in Javascript CouchDB does however support alternative view server View servers for Python, PHP, Ruby, Erlang, Perl available • Uses only the “map” part of map/reduce • No joins But the documents represent the full state of that part of the data model ... right?
  • 14. Advanced Views • Still no joins • Can perform complex calculations You can only rely on the content of the document being processed But the documents represent the full state of that part of the data model ... right? • A Reduce function can be used to aggregate calculations • Map and reduce intermediate results are indexed Once calculated for a document, they never need to be re-calculated until the document is updated It's therefore very fast! • Not as obvious how to program them
  • 15. What about transactions? • ACID compliant On a document-by-document basis Tolerant of very wide array of failure modes due to Erlang paradigms The documented way to cleanly stop a CouchDB server is to kill the process • No user-defined transactions Essentially it's auto-commit But the documents represent the full state of that part of the data model ... right? No isolation levels, so don't run your banking on it … No isolation levels to get in the way when you're storing data for a single user Effective isolation is READ_COMMITTED • No distributed transactions The world is eventually consistent A given user tied to a particular CouchDB server will always have a consistent world view
  • 16. Scaling • Master/master replication strategy • Eventually consistent replication But the documents represent the full state of that part of the data model ... right? • Requires conflict resolution in the application code This might as simple as last update wins Can equally be a user-driven process – the application code sees all conflicts of a document and can decide how to proceed • Offline working is easy In fact – in-built for AJAX applications hosted within the CouchDB database
  • 17. Weaknesses • DBs require periodic compaction All document operations (including deletion) are appended to the DB file • Under heavy update load, storage may be sub-optimal Try MongoDB, which does in-place updates – but requires greater transactional overhead as a result • SQL skills don't map (or reduce) over to CouchDB
  • 18. The known unknowns What's been left out • Security Recently introduced in 0.11.0 Pluggable authentication, defaults to CouchDB hosted _users database Together with the validation functionality fairly powerful • Caveat emptor ... There's more to the details of everything I've talked about
  • 19. Concluding ... • What's MOO doing with all this? • NoSQL databases have their place There's more to the details of everything I've talked about • SQL can do everything NoSQL can Might take rather longer to do it NoSQL is better suited for some use-cases • Many different implementations for different use-cases Each as their own strengths and weaknesses • Download and try a few!
  • 20. Questions? • Steve Storey - steves@moo.com • CouchDB - http://couchdb.apache.org/ • Further reading - http://books.couchdb.org/relax/