SlideShare a Scribd company logo
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

Managed it services
Managed it servicesManaged it services
Managed it services
Gss America
 
Saving Money with Azure Reservations
Saving Money with Azure Reservations Saving Money with Azure Reservations
Saving Money with Azure Reservations
Dileepa Rajapaksa
 
Company profile for outsourcing
Company profile for outsourcingCompany profile for outsourcing
Company profile for outsourcing
nsnanusha
 
Apresentação da Plataforma
Apresentação da Plataforma Apresentação da Plataforma
Apresentação da Plataforma Fluig
 
Web 2.0 Challenges & Opportunities
Web 2.0 Challenges & OpportunitiesWeb 2.0 Challenges & Opportunities
Web 2.0 Challenges & Opportunities
bbutler
 
If you do nothing else in your SIAM programme...make sure you do these things
If you do nothing else in your SIAM programme...make sure you do these thingsIf you do nothing else in your SIAM programme...make sure you do these things
If you do nothing else in your SIAM programme...make sure you do these things
Scopism
 
Lei de Proteção aos Dados (LGPD)
Lei de Proteção aos Dados (LGPD)Lei de Proteção aos Dados (LGPD)
Lei de Proteção aos Dados (LGPD)
Luiz Agner
 
Intune Concept.pptx
Intune Concept.pptxIntune Concept.pptx
Intune Concept.pptx
jmbrrvgzhr
 
Gestão Estratégica da TI - Apresentação
Gestão Estratégica da TI - ApresentaçãoGestão Estratégica da TI - Apresentação
Gestão Estratégica da TI - Apresentação
Mauricio Uriona Maldonado PhD
 
4 & 1/2 yrs experience in ICT Infra E- Governance Project Management in HCL ...
4 & 1/2 yrs experience  in ICT Infra E- Governance Project Management in HCL ...4 & 1/2 yrs experience  in ICT Infra E- Governance Project Management in HCL ...
4 & 1/2 yrs experience in ICT Infra E- Governance Project Management in HCL ...
Bajaj Electricals Ltd
 
Power BI reports and dashboards for Microsoft Project Server
Power BI reports and  dashboards for Microsoft Project ServerPower BI reports and  dashboards for Microsoft Project Server
Power BI reports and dashboards for Microsoft Project Server
Advaiya Solutions, Inc.
 
Espl company profile
Espl   company profileEspl   company profile
Espl company profile
Espirit Softwares Pvt Ltd
 
Enterprise content management
Enterprise content managementEnterprise content management
Enterprise content managementotnawrup
 
Make Your Debriefing Count
Make Your Debriefing CountMake Your Debriefing Count
Make Your Debriefing Count
Tan Wilson, PMP
 
PETI - Planejamento Estratégico de Tecnologia da Informação
PETI - Planejamento Estratégico de Tecnologia da InformaçãoPETI - Planejamento Estratégico de Tecnologia da Informação
PETI - Planejamento Estratégico de Tecnologia da Informação
Wagner Silva
 
Managed IT Services Pricing Models And Strategies Powerpoint Presentation Slides
Managed IT Services Pricing Models And Strategies Powerpoint Presentation SlidesManaged IT Services Pricing Models And Strategies Powerpoint Presentation Slides
Managed IT Services Pricing Models And Strategies Powerpoint Presentation Slides
SlideTeam
 
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
Wellington Monaco
 
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NETInventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
Himanshu Patel
 

What's hot (20)

Managed it services
Managed it servicesManaged it services
Managed it services
 
Saving Money with Azure Reservations
Saving Money with Azure Reservations Saving Money with Azure Reservations
Saving Money with Azure Reservations
 
Company profile for outsourcing
Company profile for outsourcingCompany profile for outsourcing
Company profile for outsourcing
 
Apresentação da Plataforma
Apresentação da Plataforma Apresentação da Plataforma
Apresentação da Plataforma
 
Web 2.0 Challenges & Opportunities
Web 2.0 Challenges & OpportunitiesWeb 2.0 Challenges & Opportunities
Web 2.0 Challenges & Opportunities
 
AMC Proposal
AMC ProposalAMC Proposal
AMC Proposal
 
If you do nothing else in your SIAM programme...make sure you do these things
If you do nothing else in your SIAM programme...make sure you do these thingsIf you do nothing else in your SIAM programme...make sure you do these things
If you do nothing else in your SIAM programme...make sure you do these things
 
Lei de Proteção aos Dados (LGPD)
Lei de Proteção aos Dados (LGPD)Lei de Proteção aos Dados (LGPD)
Lei de Proteção aos Dados (LGPD)
 
Intune Concept.pptx
Intune Concept.pptxIntune Concept.pptx
Intune Concept.pptx
 
Gestão Estratégica da TI - Apresentação
Gestão Estratégica da TI - ApresentaçãoGestão Estratégica da TI - Apresentação
Gestão Estratégica da TI - Apresentação
 
4 & 1/2 yrs experience in ICT Infra E- Governance Project Management in HCL ...
4 & 1/2 yrs experience  in ICT Infra E- Governance Project Management in HCL ...4 & 1/2 yrs experience  in ICT Infra E- Governance Project Management in HCL ...
4 & 1/2 yrs experience in ICT Infra E- Governance Project Management in HCL ...
 
Power BI reports and dashboards for Microsoft Project Server
Power BI reports and  dashboards for Microsoft Project ServerPower BI reports and  dashboards for Microsoft Project Server
Power BI reports and dashboards for Microsoft Project Server
 
Espl company profile
Espl   company profileEspl   company profile
Espl company profile
 
Enterprise content management
Enterprise content managementEnterprise content management
Enterprise content management
 
Make Your Debriefing Count
Make Your Debriefing CountMake Your Debriefing Count
Make Your Debriefing Count
 
PETI - Planejamento Estratégico de Tecnologia da Informação
PETI - Planejamento Estratégico de Tecnologia da InformaçãoPETI - Planejamento Estratégico de Tecnologia da Informação
PETI - Planejamento Estratégico de Tecnologia da Informação
 
Managed IT Services Pricing Models And Strategies Powerpoint Presentation Slides
Managed IT Services Pricing Models And Strategies Powerpoint Presentation SlidesManaged IT Services Pricing Models And Strategies Powerpoint Presentation Slides
Managed IT Services Pricing Models And Strategies Powerpoint Presentation Slides
 
AS08
AS08AS08
AS08
 
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
LGPD | FASE-1: PREPARAÇÃO | JORNADA DE ADEQUAÇÃO | SGPD - SISTEMA DE GESTÃO D...
 
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NETInventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
 

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 MySQL
ohiocore
 
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
peter_marklund
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
Michael MacDonald
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
dosire
 
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
Davide Mauri
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
Dr 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 world
Alessandro Alpi
 
ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018
Tessa Ledwith
 
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
GeraldBenischke
 
Gemboys
GemboysGemboys
Gemboys
Filippo Dino
 
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
David Boike
 
Flickr Architecture Presentation
Flickr Architecture PresentationFlickr Architecture Presentation
Flickr Architecture Presentationweb25
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
Gautam Rege
 
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
Wynn 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 Practices
David Keener
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB Sync
Shaun Haber
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
rschmukler
 
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
 
ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018ExpertTalks Manchester September 2018
ExpertTalks Manchester September 2018
 
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
 
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 Hugo
Brian 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 Ansible
Brian 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 Vagrant
Brian Hogan
 
Docker
DockerDocker
Docker
Brian Hogan
 
Getting Started Contributing To Open Source
Getting Started Contributing To Open SourceGetting Started Contributing To Open Source
Getting Started Contributing To Open Source
Brian Hogan
 
Rethink Frontend Development With Elm
Rethink Frontend Development With ElmRethink Frontend Development With Elm
Rethink Frontend Development With Elm
Brian 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 CoffeeScript
Brian 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 Sass
Brian Hogan
 
Building A Gem From Scratch
Building A Gem From ScratchBuilding A Gem From Scratch
Building A Gem From Scratch
Brian Hogan
 
Intro To Advanced Ruby
Intro To Advanced RubyIntro To Advanced Ruby
Intro To Advanced Ruby
Brian 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 Today
Brian 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 Complex
Brian 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 Library
Brian Hogan
 
Intro to Ruby
Intro to RubyIntro to Ruby
Intro to Ruby
Brian 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 7
Brian Hogan
 
Make GUI Apps with Shoes
Make GUI Apps with ShoesMake GUI Apps with Shoes
Make GUI Apps with Shoes
Brian Hogan
 
The Why Of Ruby
The Why Of RubyThe Why Of Ruby
The Why Of Ruby
Brian 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

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 

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.