Skip to content

Instantly share code, notes, and snippets.

@stujo
Last active August 29, 2015 14:20
Show Gist options
  • Save stujo/27b66e5a0df1cd210759 to your computer and use it in GitHub Desktop.
Save stujo/27b66e5a0df1cd210759 to your computer and use it in GitHub Desktop.
ORM Notes

Object Relational Mapping

Implementation for SQL RDBMS Databases in Ruby

  • Domain Specific Model classes are defined for specific tables
  • Each Model class maps to a table
  • Class methods map to actions on the table
    • find, -> SELECT
  • An instance of the Model class maps to single row in the table
  • An instance may refer to a 'yet-to-be-inserted' row
  • The id ruby property maps to the PRIMARY KEY ID
  • Instance methods map to actions on that single row
    • save -> INSERT or UPDATE
    • destroy -> DELETE

Discussion

  • What about Related Objects?

Optional Code Along

  • cd parksandrec
  • bundle
  • irb -r ./parksandrec.rb

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment