SlideShare a Scribd company logo
1 of 17
Download to read offline
Using Multiple
Databases in Merb
  With special guest CouchDB



    Wesley Beary | Software Engineer
          wesley@plinky.com
DataMapper!
•   database.yml maps first connection to
    the :default repository.
•   database.yml is a hash, each
    environment can have many keys.
•   Assign the primary database to
    the :default key and other databases to
    distinct meaningful keys (or not).

                       Wesley Beary | Software Engineer | wesley@plinky.com
# TODO: use them?
•   run a specific command:
    repository(:key) { some_command(s) }
    or
    Foo.all(:repository => repository(:key))

•   set a model’s storage location:
    class Bar
      def self.default_repository_name
        :key
      end
    end

                        Wesley Beary | Software Engineer | wesley@plinky.com
Dear Sir or Madam,

        Why should I care?

                      Thanks,
                      The Audience




                 Wesley Beary | Software Engineer | wesley@plinky.com
one_size.should_not
     fit(:all)




          Wesley Beary | Software Engineer | wesley@plinky.com
Example, Pretty Please?
•   MySQL                        •   CouchDB

•   +/- schema based             •   +/- schema-less

•   + complex joins/queries      •   + map/reduce

•   + established security       •   - security TBA

•   - not good at blobs          •   + good at blobs




                              Wesley Beary | Software Engineer | wesley@plinky.com
CouchDB?

•   RESTful
•   javascript queries
•   json data
•   file attachments



                         Wesley Beary | Software Engineer | wesley@plinky.com
How about a use case?
Muddle: merb + couchdb == tumblelog




                  Wesley Beary | Software Engineer | wesley@plinky.com
STI: Icky Tables

•   Single table inheritance gets gross.
•   Usually the fields for the parent and
    every child go on EVERY record.
•   CouchDB lets you store just what you
    need on a case by case basis.


                        Wesley Beary | Software Engineer | wesley@plinky.com
Tumbling

•   Each posts may have vastly different
    content/fields from other posts.
•   There are many different child classes
    derived from Post.
•   Some posts have associated files,
    attachments help keep it organized.


                       Wesley Beary | Software Engineer | wesley@plinky.com
Random Posts




      Wesley Beary | Software Engineer | wesley@plinky.com
Direct From CouchDB!




          Wesley Beary | Software Engineer | wesley@plinky.com
Wesley Beary | Software Engineer | wesley@plinky.com
Details?
•   User data is safely stored in mysql.
•   Files save and load from CouchDB.
•   Mostly a proof of concept, needs work to
    flesh out the details still.
•   No load/performance testing just yet,
    hard to say how production-worthy parts
    might be.

                        Wesley Beary | Software Engineer | wesley@plinky.com
Caution Associations
          Ahead
•   define cross repository belongs
    repository(:key) do
      belongs_to :model
    end

•   define cross repository has
    has n, :models, :repository => repository(:key)




                               Wesley Beary | Software Engineer | wesley@plinky.com
Play along at home!
http://github.com/monki/muddle




               Wesley Beary | Software Engineer | wesley@plinky.com
Questions?
http://github.com/monki/muddle




               Wesley Beary | Software Engineer | wesley@plinky.com

More Related Content

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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 🐘
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Multiple Databases with Merb

  • 1. Using Multiple Databases in Merb With special guest CouchDB Wesley Beary | Software Engineer wesley@plinky.com
  • 2. DataMapper! • database.yml maps first connection to the :default repository. • database.yml is a hash, each environment can have many keys. • Assign the primary database to the :default key and other databases to distinct meaningful keys (or not). Wesley Beary | Software Engineer | wesley@plinky.com
  • 3. # TODO: use them? • run a specific command: repository(:key) { some_command(s) } or Foo.all(:repository => repository(:key)) • set a model’s storage location: class Bar def self.default_repository_name :key end end Wesley Beary | Software Engineer | wesley@plinky.com
  • 4. Dear Sir or Madam, Why should I care? Thanks, The Audience Wesley Beary | Software Engineer | wesley@plinky.com
  • 5. one_size.should_not fit(:all) Wesley Beary | Software Engineer | wesley@plinky.com
  • 6. Example, Pretty Please? • MySQL • CouchDB • +/- schema based • +/- schema-less • + complex joins/queries • + map/reduce • + established security • - security TBA • - not good at blobs • + good at blobs Wesley Beary | Software Engineer | wesley@plinky.com
  • 7. CouchDB? • RESTful • javascript queries • json data • file attachments Wesley Beary | Software Engineer | wesley@plinky.com
  • 8. How about a use case? Muddle: merb + couchdb == tumblelog Wesley Beary | Software Engineer | wesley@plinky.com
  • 9. STI: Icky Tables • Single table inheritance gets gross. • Usually the fields for the parent and every child go on EVERY record. • CouchDB lets you store just what you need on a case by case basis. Wesley Beary | Software Engineer | wesley@plinky.com
  • 10. Tumbling • Each posts may have vastly different content/fields from other posts. • There are many different child classes derived from Post. • Some posts have associated files, attachments help keep it organized. Wesley Beary | Software Engineer | wesley@plinky.com
  • 11. Random Posts Wesley Beary | Software Engineer | wesley@plinky.com
  • 12. Direct From CouchDB! Wesley Beary | Software Engineer | wesley@plinky.com
  • 13. Wesley Beary | Software Engineer | wesley@plinky.com
  • 14. Details? • User data is safely stored in mysql. • Files save and load from CouchDB. • Mostly a proof of concept, needs work to flesh out the details still. • No load/performance testing just yet, hard to say how production-worthy parts might be. Wesley Beary | Software Engineer | wesley@plinky.com
  • 15. Caution Associations Ahead • define cross repository belongs repository(:key) do belongs_to :model end • define cross repository has has n, :models, :repository => repository(:key) Wesley Beary | Software Engineer | wesley@plinky.com
  • 16. Play along at home! http://github.com/monki/muddle Wesley Beary | Software Engineer | wesley@plinky.com
  • 17. Questions? http://github.com/monki/muddle Wesley Beary | Software Engineer | wesley@plinky.com