Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Arel - Ruby Relational Algebra
Upcoming SlideShare
Loading in …5
×

Arel - Ruby Relational Algebra

5,713 views
5,529 views

Published on

Published in: Technology
1 Comment
12 Likes
Statistics
Notes
No Downloads
Views
Total views
5,713
On SlideShare
0
From Embeds
0
Number of Embeds
46
Actions
Shares
0
Downloads
101
Comments
1
Likes
12
Embeds 0
No embeds

No notes for slide



  • How many people have heard of Arel?


  • Lots of contributors!!!

  • Math concept. Offshoot of set theory. E.F. Codd in 1970
    You use relation algebra when you use SQL.



  • Header with columns and types.

  • A set of tuples.
    Not SQL specific.
    ...But: think about tables, views, query results
    ...in AR: classes, associations

  • Selection: WHERE (restrict a set)

  • Projection: Limit the columns (SELECT ...)
  • Like SQL
  • Set operations
  • Operations on relations yield new relations.
    Implemented in code as the composite pattern.
    Note: This works because relations are immutable, which is cool.
  • Cleaned up ActiveRecord. Nice new Syntax for you.






  • Query runs on iteration






  • Cleans up everything quite nicely









  • Caution!
    Not supported by Rails. Don’t report bugs ;-)
    Subject to Arel API changes




  • Contrived example.
    Consider your code that builds queries based on data.

  • AR becomes a Data Mapper



  • Arel is split into Algebra and Engines
  • Arel supports multiple engines

  • Each engine defines CRUD operations

  • Write an ActiveRecord relation that pulls IDs from Redis and records from a table

  • ×