SlideShare a Scribd company logo
1 of 66
Rails + Legacy
  Databases
 Brian Hogan - RailsConf 2009
       twitter: bphogan
         IRC: hoganbp
Please don’t do it!
Questions?
Just kidding.
Who’s here?
Rails and Legacy
database schemas
Anything that doesn’t
follow ActiveRecord
    conventions
This is going to be
 boring, isn’t it?
I bet Obie’s business
  panel is awesome.
or that musical
patterns one...
sorry.
Simple(er) solutions
 with ActiveRecord
Simple problems
    Person
             singular
person_id
               table
firstname
lastname
             name and
middlename
             prefixed
address
city
                 ID
state
zip
Simple solutions
    Person
person_id
firstname
lastname
middlename
address
city
state
zip
Bad Column names
    Person
                 old-
person_id
                school
person_name
person_email
               prefixes
person_sex
alias_attribute
    Person
person_id
person_name
person_email
person_sex
Uglier Schemas
Really Bad
         Column Names
    Person
                Prefixes!
Person id
                 Spaces!
Person Name
                 Yikes!!
Person e-mail
Person sex
Use a View!

    Person
Person id
Person Name
Person e-mail
Person sex
Non-incrementing Keys
Try to add them.
Generate them in your
   code somehow.
Wordpress
Compound keys
Dr. Nic to the rescue.

  http://compositekeys.rubyforge.org/
Establish a
      connection
database.yml
Establish a
            connection
environment.rb
Wordpress
Foreign Keys are easy
Working with
 Legacy Data
Getting even this
was a challenge!
THIS IS NOT ALL THE
        DATA.
Data security
• Secure internal network between the database
  server and the mainframe
• Replication to the application database server using
  Microsoft DTS packages
• Access restricted at the table level
• Access granted to primary developers via views
• Access granted to third-party develpers by stored
  procedures.
Views are a security
       tool!
Views are often a
performance gain!
Stored Procedures
There’s no direct
support for stored
     procs in
  ActiveRecord...
...but the connection
   class will work!
Call a procedure
Get a return value
Get Rows
DataMapper
This is nice.
Biggest problem with
 Rails and Legacy is
 “automagical code”
DataMapper
Drawbacks?
Doesn’t work well on
    Windows yet
No Microsoft SQL
 Server support.
Moving From Legacy
Where are you coming
 from and where are
     you going?
Datatypes
Oracle
Oracle

 NUMBER datatype is
used for integers and
       floats
DATE is used for Time
     AND Date.
Oracle

NUMBER and CHAR can
   both be used
   for :boolean!
Oracle Enhanced
           Driver

• http://github.com/rsim/oracle-enhanced
   • Raimonds Simanovskis

   • Good slides on this at http://www.slideshare.net/rsim/using-ruby-on-
     rails-with-legacy-oracle-databases-presentation
SQL Server



SQL Server 2000 and
   2005 are very
     different.
SQL Server


TEXT fields with AR
    are really
   troublesome.
SQL Server
   2000-2005-sqlserver-
         adapter
                   Ken Collins

http://github.com/rails-sqlserver/2000-2005-adapter
Finally, watch out for
      triggers!
Dealing with
            Constraints
• Avoid using fixtures for tests. They’re bad news
  anyway
• Use .new() and stubs
• Duplicate validation / constraints in your code
• Use exception handling
• Use Stubble - http://github.com/dchelimsky/
  stubble
Migrating to a new
          DBMS

• rake db:schema:dump, and then paste that in as a
  new base migration
   • sometimes columns aren’t usable this way.
     Dump schema as SQL and use Regex instead
     to convert to Ruby.
MS SQL Databases


• Tables within different databases on the same
  server can be joined as if they are in the same
  database.
•

More Related Content

What's hot

establish an effective it steering committee
establish an effective it steering committeeestablish an effective it steering committee
establish an effective it steering committeeInfo-Tech Research Group
 
Health Experience: The difference between loyalty & leaving
Health Experience: The difference between loyalty & leavingHealth Experience: The difference between loyalty & leaving
Health Experience: The difference between loyalty & leavingaccenture
 
Introduction To Business Architecture – Part 1
Introduction To Business Architecture – Part 1Introduction To Business Architecture – Part 1
Introduction To Business Architecture – Part 1Alan McSweeney
 
Quest 2 and the future of metaverse v2.0 210908
Quest 2 and the future of metaverse v2.0  210908Quest 2 and the future of metaverse v2.0  210908
Quest 2 and the future of metaverse v2.0 210908Michael Lesniak
 
Using Business Architecture to enable customer experience and digital strategy
Using Business Architecture to enable customer experience and digital strategyUsing Business Architecture to enable customer experience and digital strategy
Using Business Architecture to enable customer experience and digital strategyCraig Martin
 
An Introduction into the design of business using business architecture
An Introduction into the design of business using business architectureAn Introduction into the design of business using business architecture
An Introduction into the design of business using business architectureCraig Martin
 
Digital Value Realization | BPO Presentation
Digital Value Realization | BPO PresentationDigital Value Realization | BPO Presentation
Digital Value Realization | BPO PresentationKen Polotan
 
Digital Transformation Toolkit - Overview and Approach
Digital Transformation Toolkit - Overview and ApproachDigital Transformation Toolkit - Overview and Approach
Digital Transformation Toolkit - Overview and ApproachPeterFranz6
 
Success Factors for Digital Transformation in Banking
Success Factors for Digital Transformation in BankingSuccess Factors for Digital Transformation in Banking
Success Factors for Digital Transformation in BankingTata Consultancy Services
 
Biopharma's search for sustainable growth
Biopharma's search for sustainable growthBiopharma's search for sustainable growth
Biopharma's search for sustainable growthaccenture
 
Bridging business analysis and business architecture - The Open Group webinar
Bridging business analysis and business architecture - The Open Group webinarBridging business analysis and business architecture - The Open Group webinar
Bridging business analysis and business architecture - The Open Group webinarCraig Martin
 
Bank of the future: Digital Transformation Strategy
Bank of the future: Digital Transformation StrategyBank of the future: Digital Transformation Strategy
Bank of the future: Digital Transformation StrategyNawaf Albadia
 
Risk Management Toolkit - Framework, Best Practices and Templates
Risk Management Toolkit - Framework, Best Practices and TemplatesRisk Management Toolkit - Framework, Best Practices and Templates
Risk Management Toolkit - Framework, Best Practices and TemplatesAurelien Domont, MBA
 
Digital Transformation: What it is and how to get there
Digital Transformation: What it is and how to get thereDigital Transformation: What it is and how to get there
Digital Transformation: What it is and how to get thereEconsultancy
 
Gartner - The art of the one page strategy
Gartner - The art of the one page strategyGartner - The art of the one page strategy
Gartner - The art of the one page strategyDeepak Kamboj
 
Moving Up or Down the IoT Value Chain
Moving Up or Down the IoT Value ChainMoving Up or Down the IoT Value Chain
Moving Up or Down the IoT Value ChainDr. Mazlan Abbas
 
B2B Sales of the Future
B2B Sales of the FutureB2B Sales of the Future
B2B Sales of the Futureaccenture
 
Accenture Tech Vision 2020 - Overview
Accenture Tech Vision 2020 - OverviewAccenture Tech Vision 2020 - Overview
Accenture Tech Vision 2020 - Overviewaccenture
 
Modern HR, Communication, & Leadership Best Practices With Microsoft 365
Modern HR, Communication, & Leadership Best Practices With Microsoft 365Modern HR, Communication, & Leadership Best Practices With Microsoft 365
Modern HR, Communication, & Leadership Best Practices With Microsoft 365Richard Harbridge
 

What's hot (20)

establish an effective it steering committee
establish an effective it steering committeeestablish an effective it steering committee
establish an effective it steering committee
 
Health Experience: The difference between loyalty & leaving
Health Experience: The difference between loyalty & leavingHealth Experience: The difference between loyalty & leaving
Health Experience: The difference between loyalty & leaving
 
Introduction To Business Architecture – Part 1
Introduction To Business Architecture – Part 1Introduction To Business Architecture – Part 1
Introduction To Business Architecture – Part 1
 
Quest 2 and the future of metaverse v2.0 210908
Quest 2 and the future of metaverse v2.0  210908Quest 2 and the future of metaverse v2.0  210908
Quest 2 and the future of metaverse v2.0 210908
 
Using Business Architecture to enable customer experience and digital strategy
Using Business Architecture to enable customer experience and digital strategyUsing Business Architecture to enable customer experience and digital strategy
Using Business Architecture to enable customer experience and digital strategy
 
Call center business plan
Call center business planCall center business plan
Call center business plan
 
An Introduction into the design of business using business architecture
An Introduction into the design of business using business architectureAn Introduction into the design of business using business architecture
An Introduction into the design of business using business architecture
 
Digital Value Realization | BPO Presentation
Digital Value Realization | BPO PresentationDigital Value Realization | BPO Presentation
Digital Value Realization | BPO Presentation
 
Digital Transformation Toolkit - Overview and Approach
Digital Transformation Toolkit - Overview and ApproachDigital Transformation Toolkit - Overview and Approach
Digital Transformation Toolkit - Overview and Approach
 
Success Factors for Digital Transformation in Banking
Success Factors for Digital Transformation in BankingSuccess Factors for Digital Transformation in Banking
Success Factors for Digital Transformation in Banking
 
Biopharma's search for sustainable growth
Biopharma's search for sustainable growthBiopharma's search for sustainable growth
Biopharma's search for sustainable growth
 
Bridging business analysis and business architecture - The Open Group webinar
Bridging business analysis and business architecture - The Open Group webinarBridging business analysis and business architecture - The Open Group webinar
Bridging business analysis and business architecture - The Open Group webinar
 
Bank of the future: Digital Transformation Strategy
Bank of the future: Digital Transformation StrategyBank of the future: Digital Transformation Strategy
Bank of the future: Digital Transformation Strategy
 
Risk Management Toolkit - Framework, Best Practices and Templates
Risk Management Toolkit - Framework, Best Practices and TemplatesRisk Management Toolkit - Framework, Best Practices and Templates
Risk Management Toolkit - Framework, Best Practices and Templates
 
Digital Transformation: What it is and how to get there
Digital Transformation: What it is and how to get thereDigital Transformation: What it is and how to get there
Digital Transformation: What it is and how to get there
 
Gartner - The art of the one page strategy
Gartner - The art of the one page strategyGartner - The art of the one page strategy
Gartner - The art of the one page strategy
 
Moving Up or Down the IoT Value Chain
Moving Up or Down the IoT Value ChainMoving Up or Down the IoT Value Chain
Moving Up or Down the IoT Value Chain
 
B2B Sales of the Future
B2B Sales of the FutureB2B Sales of the Future
B2B Sales of the Future
 
Accenture Tech Vision 2020 - Overview
Accenture Tech Vision 2020 - OverviewAccenture Tech Vision 2020 - Overview
Accenture Tech Vision 2020 - Overview
 
Modern HR, Communication, & Leadership Best Practices With Microsoft 365
Modern HR, Communication, & Leadership Best Practices With Microsoft 365Modern HR, Communication, & Leadership Best Practices With Microsoft 365
Modern HR, Communication, & Leadership Best Practices With Microsoft 365
 

Similar to Rails and Legacy Databases - RailsConf 2009

Under the Hood with MySQL
Under the Hood with MySQLUnder the Hood with MySQL
Under the Hood with MySQLohiocore
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDavide Mauri
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Mvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldMvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldAlessandro Alpi
 
We're going on a bug hunt! Experts Talk Manchester 2018
We're going on a bug hunt! Experts Talk Manchester 2018We're going on a bug hunt! Experts Talk Manchester 2018
We're going on a bug hunt! Experts Talk Manchester 2018GeraldBenischke
 
ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018Tessa Ledwith
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeDavid Boike
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentationweb25
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchWynn Netherland
 
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Mydbops
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best PracticesDavid Keener
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB SyncShaun Haber
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Railsrschmukler
 
Ajax World2008 Eric Farrar
Ajax World2008 Eric FarrarAjax World2008 Eric Farrar
Ajax World2008 Eric Farrarrajivmordani
 

Similar to Rails and Legacy Databases - RailsConf 2009 (20)

Under the Hood with MySQL
Under the Hood with MySQLUnder the Hood with MySQL
Under the Hood with MySQL
 
Rails For Legacy Apps
Rails For Legacy AppsRails For Legacy Apps
Rails For Legacy Apps
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Dapper: the microORM that will change your life
Dapper: the microORM that will change your lifeDapper: the microORM that will change your life
Dapper: the microORM that will change your life
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Mvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops worldMvp4 croatia - Being a dba in a devops world
Mvp4 croatia - Being a dba in a devops world
 
We're going on a bug hunt! Experts Talk Manchester 2018
We're going on a bug hunt! Experts Talk Manchester 2018We're going on a bug hunt! Experts Talk Manchester 2018
We're going on a bug hunt! Experts Talk Manchester 2018
 
ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018
 
Gemboys
GemboysGemboys
Gemboys
 
Modeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught Me
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentation
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
MongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouchMongoDB - Ruby document store that doesn't rhyme with ouch
MongoDB - Ruby document store that doesn't rhyme with ouch
 
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB Sync
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
Ajax World2008 Eric Farrar
Ajax World2008 Eric FarrarAjax World2008 Eric Farrar
Ajax World2008 Eric Farrar
 

More from Brian Hogan

Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoBrian Hogan
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleBrian Hogan
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantBrian Hogan
 
Getting Started Contributing To Open Source
Getting Started Contributing To Open SourceGetting Started Contributing To Open Source
Getting Started Contributing To Open SourceBrian Hogan
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With ElmBrian Hogan
 
Testing Client-side Code with Jasmine and CoffeeScript
Testing Client-side Code with Jasmine and CoffeeScriptTesting Client-side Code with Jasmine and CoffeeScript
Testing Client-side Code with Jasmine and CoffeeScriptBrian Hogan
 
FUD-Free Accessibility for Web Developers - Also, Cake.
FUD-Free Accessibility for Web Developers - Also, Cake.FUD-Free Accessibility for Web Developers - Also, Cake.
FUD-Free Accessibility for Web Developers - Also, Cake.Brian Hogan
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web DesignBrian Hogan
 
Web Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassWeb Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassBrian Hogan
 
Building A Gem From Scratch
Building A Gem From ScratchBuilding A Gem From Scratch
Building A Gem From ScratchBrian Hogan
 
Intro To Advanced Ruby
Intro To Advanced RubyIntro To Advanced Ruby
Intro To Advanced RubyBrian Hogan
 
Turning Passion Into Words
Turning Passion Into WordsTurning Passion Into Words
Turning Passion Into WordsBrian Hogan
 
HTML5 and CSS3 Today
HTML5 and CSS3 TodayHTML5 and CSS3 Today
HTML5 and CSS3 TodayBrian Hogan
 
Web Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexWeb Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexBrian Hogan
 
Stop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard LibraryStop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard LibraryBrian Hogan
 
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Brian Hogan
 
Make GUI Apps with Shoes
Make GUI Apps with ShoesMake GUI Apps with Shoes
Make GUI Apps with ShoesBrian Hogan
 

More from Brian Hogan (20)

Creating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with HugoCreating and Deploying Static Sites with Hugo
Creating and Deploying Static Sites with Hugo
 
Automating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and AnsibleAutomating the Cloud with Terraform, and Ansible
Automating the Cloud with Terraform, and Ansible
 
Create Development and Production Environments with Vagrant
Create Development and Production Environments with VagrantCreate Development and Production Environments with Vagrant
Create Development and Production Environments with Vagrant
 
Docker
DockerDocker
Docker
 
Getting Started Contributing To Open Source
Getting Started Contributing To Open SourceGetting Started Contributing To Open Source
Getting Started Contributing To Open Source
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
 
Testing Client-side Code with Jasmine and CoffeeScript
Testing Client-side Code with Jasmine and CoffeeScriptTesting Client-side Code with Jasmine and CoffeeScript
Testing Client-side Code with Jasmine and CoffeeScript
 
FUD-Free Accessibility for Web Developers - Also, Cake.
FUD-Free Accessibility for Web Developers - Also, Cake.FUD-Free Accessibility for Web Developers - Also, Cake.
FUD-Free Accessibility for Web Developers - Also, Cake.
 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
 
Web Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassWeb Development with CoffeeScript and Sass
Web Development with CoffeeScript and Sass
 
Building A Gem From Scratch
Building A Gem From ScratchBuilding A Gem From Scratch
Building A Gem From Scratch
 
Intro To Advanced Ruby
Intro To Advanced RubyIntro To Advanced Ruby
Intro To Advanced Ruby
 
Turning Passion Into Words
Turning Passion Into WordsTurning Passion Into Words
Turning Passion Into Words
 
HTML5 and CSS3 Today
HTML5 and CSS3 TodayHTML5 and CSS3 Today
HTML5 and CSS3 Today
 
Web Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To ComplexWeb Development With Ruby - From Simple To Complex
Web Development With Ruby - From Simple To Complex
 
Stop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard LibraryStop Reinventing The Wheel - The Ruby Standard Library
Stop Reinventing The Wheel - The Ruby Standard Library
 
Intro to Ruby
Intro to RubyIntro to Ruby
Intro to Ruby
 
Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7Intro to Ruby - Twin Cities Code Camp 7
Intro to Ruby - Twin Cities Code Camp 7
 
Make GUI Apps with Shoes
Make GUI Apps with ShoesMake GUI Apps with Shoes
Make GUI Apps with Shoes
 
The Why Of Ruby
The Why Of RubyThe Why Of Ruby
The Why Of Ruby
 

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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 Servicegiselly40
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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 MenDelhi Call girls
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 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...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Rails and Legacy Databases - RailsConf 2009

Editor's Notes

  1. So the main thing I want you to take away from this talk is...
  2. The point of this talk is to show you that there are ways to work with legacy systems, but that you really, should try to work around them.
  3. How many people here are new to Rails? How many people have to work with legacy databases? How many people want to learn how to work with legacy?
  4. This is a topic that’s close to me because I work days at a university that uses Oracle and SQL Server databases. In order to use Rails, there were a lot of things I had to figure out.
  5. A legacy database could be anything that existed before Rails, like a wordpress blog or a custom project management app.
  6. It’s important to note that these aren’t Rails limitations, but rather ActiveRecord limitations.
  7. So, we’re going to talk about legacy schemas and Rails. Things like bad table names, non-incrementing primary keys, stored procedures, compound keys
  8. We’ll look at some simple fixes first, like overriding table names and primary keys...
  9. and then look at some other ways we can make our code easier to read and write while still leveraging the power of Rails
  10. ActiveRecord provides mechanisms to handle some simple cases for us.
  11. Rails’ alias_attribute method is a macro for redefining the method at runtime. However, it only works with fieldnames that don’t violate Rails’ conventions.
  12. Sometimes the stuff that ActiveRecord gives you just isn’t enough.
  13. Some databases (SQL SERVER) let you have column names like this. Soaces, dashes, mixed case.
  14. Views to the rescue. MySQL, Microsoft SQL Server, and Oracle support inserting into views too, so your Rails database adapter will never know.
  15. Can anyone give me examples of non incrementing keys? Some good examples?
  16. Not always possible if there’s a certain level of beaurocracy in your institution. Some people also just think meaningful keys are the most bestest idea.
  17. This example is BAD BAD BAD. If you don’t know why, then please close your laptop and go sit in the corner.
  18. Let’s take a look at using Rails with an existing wordpress database.
  19. This is incredibly common. One of our databases joins 5 columns for course records.
  20. Wordpress and Rails can work well together.
  21. Some public directory information from a university. It’s fed from a Unisys mainframe on a nightly basis using flatfiles.
  22. The feed also includes social security numbers. We have to protect those
  23. Never forget that views are a security tool. Aside from the benefit they give us with regard to changing how data looks, we can use them to abstract availability of data. I *never* see these used in Rails.
  24. In some databases you can use views to cut down complex join logic and still treat them like tables. MySQL doesn’t allow subselects, but MS SQL sure does.
  25. Sometimes logic is encapsulated within the database.
  26. This throws the results away, but it’s fine if you just want to call something that has no return value. Execute is good for calling any arbitrary SQL, but
  27. This will get you a single return value from a procedure.
  28. Results come back as an array of hashes, so you access them a little differently, but it’s still pretty nice. A little meta-magic and you can map these to properties of a new instance.
  29. There is no escape!
  30. Using Oracle? MySQL? PostgreSQL? Try DataMapper!
  31. This declares properties and methods. This has lots of potential.
  32. If you can declare your columns like you can with DataMapper or even with a view, you’ve solved the major problems.
  33. Cygwin and other methods, but it’s known to be slow.
  34. A call for help. I know virtually nothing about DataMapper, but a lot about SQL Server. There’s been interest, but no volunteers yet. I’m tempted but I need help.
  35. What are some strategies you can use to move from legacy systems?
  36. If you’re going to move from one platform to another, you need to know what the differences between the platforms.
  37. Each database manufacturer has different types.
  38. NUMBER datatype can be used for floats and integers
  39. DATE is used for times and dates.
  40. NUMBER and CHAR - zero and one - for booleans.
  41. Raimonds is a pretty swell guy, and he’s done some great work on this driver which makes working with Oracle very nice.
  42. They’re deprecated anyway. If you have to use a database that uses this type, you have to watch out for statements that use equality.
  43. This solves a lot of stuff. Different datatypes, date fixes, and excellent stored procedure support.
  44. Legacy databases tend to have a lot of these. You need to write code to handle exceptions that your ORM classes might throw if a trigger causes constraints to be violated or if triggers start doing strange things.