SlideShare a Scribd company logo
1 of 118
Schema Design
           for Riak
             Sean Cribbs
          Developer Advocate




basho
Thinking
        Non-Relationally


basho
“There is no spoon
            schema.”


basho
There is an
        application.


basho
What you lose




basho
What you lose

        •Tables




basho
What you lose

        •Tables
        •Foreign keys and constraints




basho
What you lose

        •Tables
        •Foreign keys and constraints
        •ACID



basho
What you lose

        •Tables
        •Foreign keys and constraints
        •ACID
        •Sophisticated query planners


basho
What you lose

        •Tables
        •Foreign keys and constraints
        •ACID
        •Sophisticated query planners
        •Declarative query language (SQL)
basho
What you gain




basho
What you gain

        •More flexible, fluid designs




basho
What you gain

        •More flexible, fluid designs
        •More natural data representations



basho
What you gain

        •More flexible, fluid designs
        •More natural data representations
        •Scaling without pain


basho
What you gain

        •More flexible, fluid designs
        •More natural data representations
        •Scaling without pain
        •Reduced operational complexity

basho
Lose the crutches




basho
Lose the crutches

        •Sparse data (optional/multi-value fields)




basho
Lose the crutches

        •Sparse data (optional/multi-value fields)
        •Richer data structures



basho
Lose the crutches

        •Sparse data (optional/multi-value fields)
        •Richer data structures
        •Meaningful identifiers


basho
Lose the crutches

        •Sparse data (optional/multi-value fields)
        •Richer data structures
        •Meaningful identifiers
        •Innovative access patterns

basho
Eventual Consistency




basho
Eventual Consistency
        •You are already dealing with
          inconsistency (e.g. caching, read slave)




basho
Eventual Consistency
        •You are already dealing with
          inconsistency (e.g. caching, read slave)

        •Plan for EC instead of triaging



basho
Eventual Consistency
        •You are already dealing with
          inconsistency (e.g. caching, read slave)

        •Plan for EC instead of triaging
         •Determine resolution processes


basho
Eventual Consistency
        •You are already dealing with
          inconsistency (e.g. caching, read slave)

        •Plan for EC instead of triaging
         •Determine resolution processes
         •Weigh risk of conflicts and emergent
            issues


basho
Know your data



basho
Make your Top 10 list




basho
Make your Top 10 list

        •Frequently requested pages/screens




basho
Make your Top 10 list

        •Frequently requested pages/screens
        •Slow queries



basho
Make your Top 10 list

        •Frequently requested pages/screens
        •Slow queries
        •Secondary indexes


basho
Make your Top 10 list

        •Frequently requested pages/screens
        •Slow queries
        •Secondary indexes
        •Complicated joins or aggregations

basho
Analyze




basho
Analyze

        •Interdependencies, coupling




basho
Analyze

        •Interdependencies, coupling
        •Cardinalities of relationships



basho
Analyze

        •Interdependencies, coupling
        •Cardinalities of relationships
        •Access pattern


basho
Analyze

        •Interdependencies, coupling
        •Cardinalities of relationships
        •Access pattern
        •Shoehorned structures

basho
Example



basho
basho
basho
Top queries
basho
List Features
basho
Reorder Features
basho
Regroup Features
basho
Edit Feature
basho
List Folders
basho
Project Statistics
basho
projects          users


               folders


        features   milestones

           project_items



        Current Schema
basho
projects          users


                      folders

   artificial
   ordering    features   milestones

                  project_items



               Current Schema
basho
projects          users
           additional
          key for stats


                             folders

   artificial
   ordering           features   milestones

                          project_items



                  Current Schema
basho
projects          users
           additional
          key for stats
                                                             BLOB
                             folders                        columns



   artificial                                          serialized
   ordering           features   milestones           parse tree


                                                      formatted
                          project_items               plain text




                  Current Schema
basho
collaborator


                            projects               users
           additional
          key for stats
                                                                  BLOB
                             folders                             columns



   artificial                                               serialized
   ordering           features   milestones                parse tree


                                                           formatted
                          project_items                    plain text




                  Current Schema
basho
collaborator


                            projects                users
           additional
          key for stats                     owner
                                                                   BLOB
                             folders                              columns



   artificial                                                serialized
   ordering           features   milestones                 parse tree


                                                            formatted
                          project_items                     plain text




                  Current Schema
basho
Observations




basho
Observations

        •Features and milestones are disjunct,
          except in list participation




basho
Observations

        •Features and milestones are disjunct,
          except in list participation

        •Opacity of serialized BLOB data



basho
Observations

        •Features and milestones are disjunct,
          except in list participation

        •Opacity of serialized BLOB data
        •Duplication of relationships -
          collaborator-owner, project-folder-item



basho
List/Reorder Features




basho
List/Reorder Features

        • AJAX postback was
          already “total” ordering




basho
List/Reorder Features

        • AJAX postback was
           already “total” ordering

        • List is really a property
           of the parent “folder”




basho
List/Reorder Features

        • AJAX postback was
           already “total” ordering

        • List is really a property
           of the parent “folder”

        • Membership, order are
           coupled concepts




basho
Links in Riak




basho
Links in Riak

        •Lightweight pointers, like HTML <link>
          tags.




basho
Links in Riak

        •Lightweight pointers, like HTML <link>
          tags.

        •Composed of bucket, key, tag


basho
Links in Riak

        •Lightweight pointers, like HTML <link>
          tags.

        •Composed of bucket, key, tag
        •Traversable through “link-walking”

basho
Riak: List/Reorder
             Features




basho
Riak: List/Reorder
                Features
        •Store list of features and milestones as
          links on folder, with index as tag




basho
Riak: List/Reorder
                Features
        •Store list of features and milestones as
          links on folder, with index as tag

        •Query: Follow links to items, map values
          (with index), reduce sort




basho
Riak: List/Reorder
                Features
        •Store list of features and milestones as
          links on folder, with index as tag

        •Query: Follow links to items, map values
          (with index), reduce sort

        •One write to order list, easy to link-walk

basho
Riak: List/Reorder
                Features
        •Store list of features and milestones as
          links on folder, with index as tag

        •Query: Follow links to items, map values
          (with index), reduce sort

        •One write to order list, easy to link-walk
        • Concurrent writes may conflict
basho
Regroup Features




basho
Regroup Features

        • Changing foreign key
          to folder




basho
Regroup Features

        • Changing foreign key
          to folder

        • Recalculate order for
          both lists (multiple
          UPDATE statements)




basho
Riak: Regroup
           Features




basho
Riak: Regroup
                  Features
        •Already solved for us by folder owning
          list as links




basho
Riak: Regroup
                  Features
        •Already solved for us by folder owning
          list as links

        •List order still recalculated



basho
Riak: Regroup
                  Features
        •Already solved for us by folder owning
          list as links

        •List order still recalculated
        •Two writes (vs. N for relational)


basho
Riak: Regroup
                  Features
        •Already solved for us by folder owning
          list as links

        •List order still recalculated
        •Two writes (vs. N for relational)
        • No transactions, need extra info for
          conflict resolution


basho
Edit Feature




basho
Edit Feature
        • Required two
          representations (text,
          tree), both stored as
          BLOBs




basho
Edit Feature
        • Required two
          representations (text,
          tree), both stored as
          BLOBs

        • Application
          deserializes tree to
          present web form,
          recreates text on save



basho
Composition




basho
Composition

        •Sometimes called “denormalization”




basho
Composition

        •Sometimes called “denormalization”
        •Store dependent data in the same object
          as the parent




basho
Composition

        •Sometimes called “denormalization”
        •Store dependent data in the same object
          as the parent

        •JSON, XML, Erlang terms

basho
Riak: Edit Feature




basho
Riak: Edit Feature

        •Already denormalized!




basho
Riak: Edit Feature

        •Already denormalized!
        •Now parse tree can have the same
          format (JSON, XML), exposing it to other
          types of processing




basho
Riak: Edit Feature

        •Already denormalized!
        •Now parse tree can have the same
          format (JSON, XML), exposing it to other
          types of processing

        •Individual objects larger

basho
List Folders




basho
List Folders

        • Number of folders is
          small per project




basho
List Folders

        • Number of folders is
          small per project

        • Essentially unordered
          within project




basho
Riak: List Folders




basho
Riak: List Folders
        • Store links to folder
          objects (or entire list) in
          project




basho
Riak: List Folders
        • Store links to folder
          objects (or entire list) in
          project

        • Simple link-walking or
          map-reduce to get
          folders




basho
Riak: List Folders
        • Store links to folder
          objects (or entire list) in
          project

        • Simple link-walking or
          map-reduce to get
          folders

        • Two writes required, or
          move feature links/
          order to project


basho
Riak: List Folders
        • Store links to folder         • Parameterized bucket
          objects (or entire list) in     based on project key
          project

        • Simple link-walking or
          map-reduce to get
          folders

        • Two writes required, or
          move feature links/
          order to project


basho
Riak: List Folders
        • Store links to folder         • Parameterized bucket
          objects (or entire list) in     based on project key
          project
                                        • One write to add folder
        • Simple link-walking or
          map-reduce to get
          folders

        • Two writes required, or
          move feature links/
          order to project


basho
Riak: List Folders
        • Store links to folder         • Parameterized bucket
          objects (or entire list) in     based on project key
          project
                                        • One write to add folder
        • Simple link-walking or
          map-reduce to get             • List keys is expensive
          folders

        • Two writes required, or
          move feature links/
          order to project


basho
Project Statistics




basho
Project Statistics

        • Relational design had
          per-feature counters
          (maintained by app)




basho
Project Statistics

        • Relational design had
          per-feature counters
          (maintained by app)

        • Extra foreign key sped
          up aggregation by
          reducing joins




basho
Riak: Project Statistics




basho
Riak: Project Statistics
        •Use scatter-gather: Map-reduce was
          made for this type of problem!




basho
Riak: Project Statistics
        •Use scatter-gather: Map-reduce was
          made for this type of problem!

        •Take advantage of now-transparent
          internal format of feature objects




basho
Riak: Project Statistics
        •Use scatter-gather: Map-reduce was
          made for this type of problem!

        •Take advantage of now-transparent
          internal format of feature objects

        •Query: Follow links to features, map per-
          feature counters, reduce summarize the
          counters

basho
Awkward Fits




basho
Awkward Fits

        •User uniqueness constraint




basho
Awkward Fits

        •User uniqueness constraint
         •“double-click” problem




basho
Awkward Fits

        •User uniqueness constraint
         •“double-click” problem
        •Existing authentication solutions



basho
Awkward Fits

        •User uniqueness constraint
         •“double-click” problem
        •Existing authentication solutions
        •Project membership


basho
Awkward Fits

        •User uniqueness constraint
         •“double-click” problem
        •Existing authentication solutions
        •Project membership
         •M-to-N is hard
basho
Review




basho
Review

        •Analyze your relational model




basho
Review

        •Analyze your relational model
        •Identify pain points, take stats



basho
Review

        •Analyze your relational model
        •Identify pain points, take stats
        •Design some alternatives


basho
Review

        •Analyze your relational model
        •Identify pain points, take stats
        •Design some alternatives
        •Test, Measure, Repeat!

basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
          
        Email info@basho.com or go to
        http://www.basho.com/contact.html to talk
        with us.

                      www.basho.com


basho
Plug
        Interested in learning about support,
        consulting, or Enterprise features?
          
        Email info@basho.com or go to
        http://www.basho.com/contact.html to talk
        with us.

                        www.basho.com
               sean@basho.com
                 @seancribbs

basho

More Related Content

Viewers also liked

Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Lucidworks
 
Riak (Øredev nosql day)
Riak (Øredev nosql day)Riak (Øredev nosql day)
Riak (Øredev nosql day)
Sean Cribbs
 
Riak Operations
Riak OperationsRiak Operations
Riak Operations
gschofield
 
Riak a successful failure
Riak   a successful failureRiak   a successful failure
Riak a successful failure
GiltTech
 
Introducing Riak
Introducing RiakIntroducing Riak
Introducing Riak
Kevin Smith
 
Key-Value Stores: a practical overview
Key-Value Stores: a practical overviewKey-Value Stores: a practical overview
Key-Value Stores: a practical overview
Marc Seeger
 

Viewers also liked (20)

Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
Distributed Search in Riak - Integrating Search in a NoSQL Database: Presente...
 
Relational Databases to Riak
Relational Databases to RiakRelational Databases to Riak
Relational Databases to Riak
 
Introduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf TrainingIntroduction to Riak - Red Dirt Ruby Conf Training
Introduction to Riak - Red Dirt Ruby Conf Training
 
What is new in Riak 2.0
What is new in Riak 2.0What is new in Riak 2.0
What is new in Riak 2.0
 
Lessons learnt coverting from SQL to NoSQL
Lessons learnt coverting from SQL to NoSQLLessons learnt coverting from SQL to NoSQL
Lessons learnt coverting from SQL to NoSQL
 
Riak (Øredev nosql day)
Riak (Øredev nosql day)Riak (Øredev nosql day)
Riak (Øredev nosql day)
 
Data visualization
Data visualizationData visualization
Data visualization
 
NoSQL – Beyond the Key-Value Store
NoSQL – Beyond the Key-Value StoreNoSQL – Beyond the Key-Value Store
NoSQL – Beyond the Key-Value Store
 
Riak Operations
Riak OperationsRiak Operations
Riak Operations
 
Riak a successful failure
Riak   a successful failureRiak   a successful failure
Riak a successful failure
 
Riak - From Small to Large
Riak - From Small to LargeRiak - From Small to Large
Riak - From Small to Large
 
Distributed Key-Value Stores- Featuring Riak
Distributed Key-Value Stores- Featuring RiakDistributed Key-Value Stores- Featuring Riak
Distributed Key-Value Stores- Featuring Riak
 
Riak in Ten Minutes
Riak in Ten MinutesRiak in Ten Minutes
Riak in Ten Minutes
 
Introducing Riak
Introducing RiakIntroducing Riak
Introducing Riak
 
Riak: A friendly key/value store for the web.
Riak: A friendly key/value store for the web.Riak: A friendly key/value store for the web.
Riak: A friendly key/value store for the web.
 
Webinar: How Leading Healthcare Companies use MongoDB
Webinar: How Leading Healthcare Companies use MongoDBWebinar: How Leading Healthcare Companies use MongoDB
Webinar: How Leading Healthcare Companies use MongoDB
 
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
Microservices Practitioner Summit Jan '15 - Don't Build a Distributed Monolit...
 
Key-Value Stores: a practical overview
Key-Value Stores: a practical overviewKey-Value Stores: a practical overview
Key-Value Stores: a practical overview
 
Microsoft Modern Analytics
Microsoft Modern AnalyticsMicrosoft Modern Analytics
Microsoft Modern Analytics
 
Modern Data Warehousing with the Microsoft Analytics Platform System
Modern Data Warehousing with the Microsoft Analytics Platform SystemModern Data Warehousing with the Microsoft Analytics Platform System
Modern Data Warehousing with the Microsoft Analytics Platform System
 

Similar to Schema Design for Riak

Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Justin Smestad
 
Riak seattle-meetup-august
Riak seattle-meetup-augustRiak seattle-meetup-august
Riak seattle-meetup-august
pharkmillups
 
BISAC Identification Committee -- ISTC
BISAC Identification Committee -- ISTCBISAC Identification Committee -- ISTC
BISAC Identification Committee -- ISTC
bisg
 
Nyc hadoop meetup introduction to h base
Nyc hadoop meetup   introduction to h baseNyc hadoop meetup   introduction to h base
Nyc hadoop meetup introduction to h base
智杰 付
 

Similar to Schema Design for Riak (20)

Hashing gt1
Hashing gt1Hashing gt1
Hashing gt1
 
Using Basho Bench to Load Test Distributed Applications
Using Basho Bench to Load Test Distributed ApplicationsUsing Basho Bench to Load Test Distributed Applications
Using Basho Bench to Load Test Distributed Applications
 
Thoughtbot Family: Bourbon, Neat, Bitters, Refills
Thoughtbot Family: Bourbon, Neat, Bitters, RefillsThoughtbot Family: Bourbon, Neat, Bitters, Refills
Thoughtbot Family: Bourbon, Neat, Bitters, Refills
 
HBaseCon 2012 | HBase Schema Design - Ian Varley, Salesforce
HBaseCon 2012 | HBase Schema Design - Ian Varley, SalesforceHBaseCon 2012 | HBase Schema Design - Ian Varley, Salesforce
HBaseCon 2012 | HBase Schema Design - Ian Varley, Salesforce
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Building a Business on Hadoop, HBase, and Open Source Distributed Computing
Building a Business on Hadoop, HBase, and Open Source Distributed ComputingBuilding a Business on Hadoop, HBase, and Open Source Distributed Computing
Building a Business on Hadoop, HBase, and Open Source Distributed Computing
 
Intro to HBase - Lars George
Intro to HBase - Lars GeorgeIntro to HBase - Lars George
Intro to HBase - Lars George
 
Riak seattle-meetup-august
Riak seattle-meetup-augustRiak seattle-meetup-august
Riak seattle-meetup-august
 
Apache Drill talk ApacheCon 2018
Apache Drill talk ApacheCon 2018Apache Drill talk ApacheCon 2018
Apache Drill talk ApacheCon 2018
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table design
 
041512 presentation
041512 presentation041512 presentation
041512 presentation
 
BISAC Identification Committee -- ISTC
BISAC Identification Committee -- ISTCBISAC Identification Committee -- ISTC
BISAC Identification Committee -- ISTC
 
NoSQL, Apache SOLR and Apache Hadoop
NoSQL, Apache SOLR and Apache HadoopNoSQL, Apache SOLR and Apache Hadoop
NoSQL, Apache SOLR and Apache Hadoop
 
Nyc hadoop meetup introduction to h base
Nyc hadoop meetup   introduction to h baseNyc hadoop meetup   introduction to h base
Nyc hadoop meetup introduction to h base
 
Apache Drill
Apache DrillApache Drill
Apache Drill
 
HBase Schema Design - HBase-Con 2012
HBase Schema Design - HBase-Con 2012HBase Schema Design - HBase-Con 2012
HBase Schema Design - HBase-Con 2012
 
Sap abap course content
Sap abap course contentSap abap course content
Sap abap course content
 
CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...
CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...
CouchDB at its Core: Global Data Storage and Rich Incremental Indexing at Clo...
 
Apache Spark's Built-in File Sources in Depth
Apache Spark's Built-in File Sources in DepthApache Spark's Built-in File Sources in Depth
Apache Spark's Built-in File Sources in Depth
 
Plone for Education: Bibliographies
Plone for Education: BibliographiesPlone for Education: Bibliographies
Plone for Education: Bibliographies
 

More from Sean Cribbs

Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)
Sean Cribbs
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
Sean Cribbs
 

More from Sean Cribbs (16)

Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)Eventually Consistent Data Structures (from strangeloop12)
Eventually Consistent Data Structures (from strangeloop12)
 
Eventually-Consistent Data Structures
Eventually-Consistent Data StructuresEventually-Consistent Data Structures
Eventually-Consistent Data Structures
 
A Case of Accidental Concurrency
A Case of Accidental ConcurrencyA Case of Accidental Concurrency
A Case of Accidental Concurrency
 
Embrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with RippleEmbrace NoSQL and Eventual Consistency with Ripple
Embrace NoSQL and Eventual Consistency with Ripple
 
Riak with node.js
Riak with node.jsRiak with node.js
Riak with node.js
 
Riak Tutorial (Øredev)
Riak Tutorial (Øredev)Riak Tutorial (Øredev)
Riak Tutorial (Øredev)
 
The Radiant Ethic
The Radiant EthicThe Radiant Ethic
The Radiant Ethic
 
Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)Introduction to Riak and Ripple (KC.rb)
Introduction to Riak and Ripple (KC.rb)
 
Riak with Rails
Riak with RailsRiak with Rails
Riak with Rails
 
Introducing Riak and Ripple
Introducing Riak and RippleIntroducing Riak and Ripple
Introducing Riak and Ripple
 
Round PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing FunctionallyRound PEG, Round Hole - Parsing Functionally
Round PEG, Round Hole - Parsing Functionally
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Achieving Parsing Sanity In Erlang
Achieving Parsing Sanity In ErlangAchieving Parsing Sanity In Erlang
Achieving Parsing Sanity In Erlang
 
Of Rats And Dragons
Of Rats And DragonsOf Rats And Dragons
Of Rats And Dragons
 
Erlang/OTP for Rubyists
Erlang/OTP for RubyistsErlang/OTP for Rubyists
Erlang/OTP for Rubyists
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Schema Design for Riak

  • 1. Schema Design for Riak Sean Cribbs Developer Advocate basho
  • 2. Thinking Non-Relationally basho
  • 3. “There is no spoon schema.” basho
  • 4. There is an application. basho
  • 6. What you lose •Tables basho
  • 7. What you lose •Tables •Foreign keys and constraints basho
  • 8. What you lose •Tables •Foreign keys and constraints •ACID basho
  • 9. What you lose •Tables •Foreign keys and constraints •ACID •Sophisticated query planners basho
  • 10. What you lose •Tables •Foreign keys and constraints •ACID •Sophisticated query planners •Declarative query language (SQL) basho
  • 12. What you gain •More flexible, fluid designs basho
  • 13. What you gain •More flexible, fluid designs •More natural data representations basho
  • 14. What you gain •More flexible, fluid designs •More natural data representations •Scaling without pain basho
  • 15. What you gain •More flexible, fluid designs •More natural data representations •Scaling without pain •Reduced operational complexity basho
  • 17. Lose the crutches •Sparse data (optional/multi-value fields) basho
  • 18. Lose the crutches •Sparse data (optional/multi-value fields) •Richer data structures basho
  • 19. Lose the crutches •Sparse data (optional/multi-value fields) •Richer data structures •Meaningful identifiers basho
  • 20. Lose the crutches •Sparse data (optional/multi-value fields) •Richer data structures •Meaningful identifiers •Innovative access patterns basho
  • 22. Eventual Consistency •You are already dealing with inconsistency (e.g. caching, read slave) basho
  • 23. Eventual Consistency •You are already dealing with inconsistency (e.g. caching, read slave) •Plan for EC instead of triaging basho
  • 24. Eventual Consistency •You are already dealing with inconsistency (e.g. caching, read slave) •Plan for EC instead of triaging •Determine resolution processes basho
  • 25. Eventual Consistency •You are already dealing with inconsistency (e.g. caching, read slave) •Plan for EC instead of triaging •Determine resolution processes •Weigh risk of conflicts and emergent issues basho
  • 27. Make your Top 10 list basho
  • 28. Make your Top 10 list •Frequently requested pages/screens basho
  • 29. Make your Top 10 list •Frequently requested pages/screens •Slow queries basho
  • 30. Make your Top 10 list •Frequently requested pages/screens •Slow queries •Secondary indexes basho
  • 31. Make your Top 10 list •Frequently requested pages/screens •Slow queries •Secondary indexes •Complicated joins or aggregations basho
  • 33. Analyze •Interdependencies, coupling basho
  • 34. Analyze •Interdependencies, coupling •Cardinalities of relationships basho
  • 35. Analyze •Interdependencies, coupling •Cardinalities of relationships •Access pattern basho
  • 36. Analyze •Interdependencies, coupling •Cardinalities of relationships •Access pattern •Shoehorned structures basho
  • 38. basho
  • 39. basho
  • 47. projects users folders features milestones project_items Current Schema basho
  • 48. projects users folders artificial ordering features milestones project_items Current Schema basho
  • 49. projects users additional key for stats folders artificial ordering features milestones project_items Current Schema basho
  • 50. projects users additional key for stats BLOB folders columns artificial serialized ordering features milestones parse tree formatted project_items plain text Current Schema basho
  • 51. collaborator projects users additional key for stats BLOB folders columns artificial serialized ordering features milestones parse tree formatted project_items plain text Current Schema basho
  • 52. collaborator projects users additional key for stats owner BLOB folders columns artificial serialized ordering features milestones parse tree formatted project_items plain text Current Schema basho
  • 54. Observations •Features and milestones are disjunct, except in list participation basho
  • 55. Observations •Features and milestones are disjunct, except in list participation •Opacity of serialized BLOB data basho
  • 56. Observations •Features and milestones are disjunct, except in list participation •Opacity of serialized BLOB data •Duplication of relationships - collaborator-owner, project-folder-item basho
  • 58. List/Reorder Features • AJAX postback was already “total” ordering basho
  • 59. List/Reorder Features • AJAX postback was already “total” ordering • List is really a property of the parent “folder” basho
  • 60. List/Reorder Features • AJAX postback was already “total” ordering • List is really a property of the parent “folder” • Membership, order are coupled concepts basho
  • 62. Links in Riak •Lightweight pointers, like HTML <link> tags. basho
  • 63. Links in Riak •Lightweight pointers, like HTML <link> tags. •Composed of bucket, key, tag basho
  • 64. Links in Riak •Lightweight pointers, like HTML <link> tags. •Composed of bucket, key, tag •Traversable through “link-walking” basho
  • 65. Riak: List/Reorder Features basho
  • 66. Riak: List/Reorder Features •Store list of features and milestones as links on folder, with index as tag basho
  • 67. Riak: List/Reorder Features •Store list of features and milestones as links on folder, with index as tag •Query: Follow links to items, map values (with index), reduce sort basho
  • 68. Riak: List/Reorder Features •Store list of features and milestones as links on folder, with index as tag •Query: Follow links to items, map values (with index), reduce sort •One write to order list, easy to link-walk basho
  • 69. Riak: List/Reorder Features •Store list of features and milestones as links on folder, with index as tag •Query: Follow links to items, map values (with index), reduce sort •One write to order list, easy to link-walk • Concurrent writes may conflict basho
  • 71. Regroup Features • Changing foreign key to folder basho
  • 72. Regroup Features • Changing foreign key to folder • Recalculate order for both lists (multiple UPDATE statements) basho
  • 73. Riak: Regroup Features basho
  • 74. Riak: Regroup Features •Already solved for us by folder owning list as links basho
  • 75. Riak: Regroup Features •Already solved for us by folder owning list as links •List order still recalculated basho
  • 76. Riak: Regroup Features •Already solved for us by folder owning list as links •List order still recalculated •Two writes (vs. N for relational) basho
  • 77. Riak: Regroup Features •Already solved for us by folder owning list as links •List order still recalculated •Two writes (vs. N for relational) • No transactions, need extra info for conflict resolution basho
  • 79. Edit Feature • Required two representations (text, tree), both stored as BLOBs basho
  • 80. Edit Feature • Required two representations (text, tree), both stored as BLOBs • Application deserializes tree to present web form, recreates text on save basho
  • 82. Composition •Sometimes called “denormalization” basho
  • 83. Composition •Sometimes called “denormalization” •Store dependent data in the same object as the parent basho
  • 84. Composition •Sometimes called “denormalization” •Store dependent data in the same object as the parent •JSON, XML, Erlang terms basho
  • 86. Riak: Edit Feature •Already denormalized! basho
  • 87. Riak: Edit Feature •Already denormalized! •Now parse tree can have the same format (JSON, XML), exposing it to other types of processing basho
  • 88. Riak: Edit Feature •Already denormalized! •Now parse tree can have the same format (JSON, XML), exposing it to other types of processing •Individual objects larger basho
  • 90. List Folders • Number of folders is small per project basho
  • 91. List Folders • Number of folders is small per project • Essentially unordered within project basho
  • 93. Riak: List Folders • Store links to folder objects (or entire list) in project basho
  • 94. Riak: List Folders • Store links to folder objects (or entire list) in project • Simple link-walking or map-reduce to get folders basho
  • 95. Riak: List Folders • Store links to folder objects (or entire list) in project • Simple link-walking or map-reduce to get folders • Two writes required, or move feature links/ order to project basho
  • 96. Riak: List Folders • Store links to folder • Parameterized bucket objects (or entire list) in based on project key project • Simple link-walking or map-reduce to get folders • Two writes required, or move feature links/ order to project basho
  • 97. Riak: List Folders • Store links to folder • Parameterized bucket objects (or entire list) in based on project key project • One write to add folder • Simple link-walking or map-reduce to get folders • Two writes required, or move feature links/ order to project basho
  • 98. Riak: List Folders • Store links to folder • Parameterized bucket objects (or entire list) in based on project key project • One write to add folder • Simple link-walking or map-reduce to get • List keys is expensive folders • Two writes required, or move feature links/ order to project basho
  • 100. Project Statistics • Relational design had per-feature counters (maintained by app) basho
  • 101. Project Statistics • Relational design had per-feature counters (maintained by app) • Extra foreign key sped up aggregation by reducing joins basho
  • 103. Riak: Project Statistics •Use scatter-gather: Map-reduce was made for this type of problem! basho
  • 104. Riak: Project Statistics •Use scatter-gather: Map-reduce was made for this type of problem! •Take advantage of now-transparent internal format of feature objects basho
  • 105. Riak: Project Statistics •Use scatter-gather: Map-reduce was made for this type of problem! •Take advantage of now-transparent internal format of feature objects •Query: Follow links to features, map per- feature counters, reduce summarize the counters basho
  • 107. Awkward Fits •User uniqueness constraint basho
  • 108. Awkward Fits •User uniqueness constraint •“double-click” problem basho
  • 109. Awkward Fits •User uniqueness constraint •“double-click” problem •Existing authentication solutions basho
  • 110. Awkward Fits •User uniqueness constraint •“double-click” problem •Existing authentication solutions •Project membership basho
  • 111. Awkward Fits •User uniqueness constraint •“double-click” problem •Existing authentication solutions •Project membership •M-to-N is hard basho
  • 113. Review •Analyze your relational model basho
  • 114. Review •Analyze your relational model •Identify pain points, take stats basho
  • 115. Review •Analyze your relational model •Identify pain points, take stats •Design some alternatives basho
  • 116. Review •Analyze your relational model •Identify pain points, take stats •Design some alternatives •Test, Measure, Repeat! basho
  • 117. Plug Interested in learning about support, consulting, or Enterprise features?   Email info@basho.com or go to http://www.basho.com/contact.html to talk with us. www.basho.com basho
  • 118. Plug Interested in learning about support, consulting, or Enterprise features?   Email info@basho.com or go to http://www.basho.com/contact.html to talk with us. www.basho.com sean@basho.com @seancribbs basho

Editor's Notes