SlideShare ist ein Scribd-Unternehmen logo
1 von 59
Arel: Ruby Relational Algebra
                             Bryan Helmkamp
                             CTO, Efficiency 2.0
                                @brynary




Arel   http://bit.ly/ggrc-arel               brynary   brynary.com
Slides                     Twitter         My blog
Arel    http://bit.ly/ggrc-arel         brynary       brynary.com
Agenda
       1. What is Arel?
       2. Relational Algebra 101
       3. Arel with ActiveRecord 3
       4. Arel under the Hood
       5. Future Possibilities


Arel         http://bit.ly/ggrc-arel        brynary   brynary.com
What is Arel?
                                           *




                                               * Mermaids do not query databases.
                                                        (Thanks, Carl)

Arel   http://bit.ly/ggrc-arel   brynary                      brynary.com
What is Arel?
       • An object-oriented interpretation of
           relational algebra in Ruby
       • Written by Nick Kallen (Twitter)
       • First commit: December 30, 2007
       • Not an ORM!
       •   http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/




Arel            http://bit.ly/ggrc-arel                 brynary                      brynary.com
Arel   http://bit.ly/ggrc-arel   brynary   brynary.com
ActiveRecord 3

                                 Arel

          Algebra                       Engines


         AR Connection Adapters

                           SQL Database

Arel   http://bit.ly/ggrc-arel          brynary   brynary.com
Relational Algebra 101



Arel     http://bit.ly/ggrc-arel   brynary   brynary.com
What’s a Relation?
       {
id:
int,
name:
string,
city:
string
}

       {
1,






“Francis”,



“NYC”







}
       {
2,






“Trotter”,



“Philly”




}
       {
3,






“Gianni”,




“LA”








}
       {
4,






“Josh”,






“NYC”







}




Arel     http://bit.ly/ggrc-arel   brynary        brynary.com
Header
       {
id:
int,
name:
string,
city:
string
}

       {
1,






“Francis”,



“NYC”







}
       {
2,






“Trotter”,



“Philly”




}
       {
3,






“Gianni”,




“LA”








}
       {
4,






“Josh”,






“NYC”







}




Arel     http://bit.ly/ggrc-arel        brynary   brynary.com
Tuples
       {
id:
int,
name:
string,
city:
string
}

       {
1,






“Francis”,



“NYC”







}
       {
2,






“Trotter”,



“Philly”




}
       {
3,






“Gianni”,




“LA”








}
       {
4,






“Josh”,






“NYC”







}




Arel     http://bit.ly/ggrc-arel            brynary   brynary.com
Core Operations
       • Selection                    • Union
       • Projection                   • Intersection
       • Join                         • Difference


Arel        http://bit.ly/ggrc-arel      brynary       brynary.com
Core Operations
       •Selection                    • Union
       • Projection                  • Intersection
       • Join                        • Difference


Arel       http://bit.ly/ggrc-arel      brynary       brynary.com
Core Operations
       • Selection                  • Union
       •Projection                  • Intersection
       • Join                       • Difference


Arel      http://bit.ly/ggrc-arel      brynary       brynary.com
Core Operations
       • Selection                    • Union
       • Projection                   • Intersection
       •Join                          • Difference


Arel        http://bit.ly/ggrc-arel      brynary       brynary.com
Core Operations
       • Selection                    •Union
       • Projection                   •Intersection
       • Join                         •Difference


Arel        http://bit.ly/ggrc-arel     brynary       brynary.com
Closure!
 relation
=
Rubyist.scoped
 #
=>
ActiveRecord::Relation

 relation
=
relation.where(:city
=>
"nyc")
 #
=>
ActiveRecord::Relation

 relation
=
relation.joins("JOIN
cities
ON
cities.id
=
city_id")
 #
=>
ActiveRecord::Relation

 relation
=
relation.limit(1)
 #
=>
ActiveRecord::Relation

 relation.to_sql
 #
=>
SELECT
*
FROM
rubyists
 




JOIN
cities
ON
cities.id
=
city_id
 




WHERE
(city_id
=
1)
LIMIT
1

Arel         http://bit.ly/ggrc-arel     brynary         brynary.com
Arel with ActiveRecord
                     (“What’s in it for me today?”)




Arel      http://bit.ly/ggrc-arel           brynary   brynary.com
Original: Hash queries

  Rubyist.find(:all,
:conditions
=>
{
  

:city
=>
"NYC",
  

:thirsty
=>
true
  })




Arel    http://bit.ly/ggrc-arel   brynary   brynary.com
Rails 2.1: Named scopes
       class
Rubyist
<
ActiveRecord::Base
       

named_scope
:nycrb,
:conditions
=>
{
       



:city
=>
"NYC"
       

}
       end

       Rubyist.nycrb.class
       #
=>
ActiveRecord::NamedScope::Scope



Arel       http://bit.ly/ggrc-arel   brynary    brynary.com
Rails 3.0: Relations

  Rubyist.where(:city
=>
"NYC")


  Rubyist.where(:city
=>
"NYC").class
  #
=>
ActiveRecord::Relation



Arel    http://bit.ly/ggrc-arel   brynary   brynary.com
Chainable and Reusable

         Rubyist.where(:city
=>
"NYC").
         

where(:thirsty
=>
true)



       nycrb
=
Rubyist.where(:city
=>
"NYC")
       nycrb.order("id
DESC").limit(10)




Arel      http://bit.ly/ggrc-arel   brynary    brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end


       <!‐‐
View
‐‐>
       <ul>
       

<%
@nycrb.each
do
|user|
%>
       



<li><%=
user.name
%></li>
       

<%
end
%>
       </ul>

Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end                        Query does not run yet


       <!‐‐
View
‐‐>
       <ul>
       

<%
@nycrb.each
do
|user|
%>
       



<li><%=
user.name
%></li>
       

<%
end
%>
       </ul>

Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end

                   SELECT
*
FROM
users
WHERE
city
=
'NYC'
       <!‐‐
View
‐‐>
       <ul>
       

<%
@nycrb.each
do
|user|
%>
       



<li><%=
user.name
%></li>
       

<%
end
%>
       </ul>

Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end

       <!‐‐
View
‐‐>
       <ul>
       

<%
cache("nycrb_people")
do
%>
       



<%
@nycrb.each
do
|user|
%>
       





<li><%=
user.name
%></li>
       



<%
end
%>
       

<%
end
%>
       </ul>
Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end

       <!‐‐
View
‐‐>      Cache hit
       <ul>
       

<%
cache("nycrb_people")
do
%>
       



<%
@nycrb.each
do
|user|
%>
       





<li><%=
user.name
%></li>
       



<%
end
%>
       

<%
end
%>
       </ul>
Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end

       <!‐‐
View
‐‐>
       <ul>                             Block is not run
       

<%
cache("nycrb_people")
do
%>
       



<%
@nycrb.each
do
|user|
%>
       





<li><%=
user.name
%></li>
       



<%
end
%>
       

<%
end
%>
       </ul>
Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
Lazy
       #
Controller
       class
RubyistsController
       

def
nycrb
       



@nycrb
=
Rubyist.where(:city
=>
"NYC")
       

end
       end

       <!‐‐
View
‐‐>
       <ul>                            SELECT never run
       

<%
cache("nycrb_people")
do
%>
       



<%
@nycrb.each
do
|user|
%>
       





<li><%=
user.name
%></li>
       



<%
end
%>
       

<%
end
%>
       </ul>
Arel        http://bit.ly/ggrc-arel          brynary   brynary.com
New Finder Methods
       •   where                             •   offset

       •   having                            •   joins

       •   select                            •   includes

       •   group                             •   lock

       •   order                             •   readonly

       •   limit                             •   from



Arel               http://bit.ly/ggrc-arel         brynary   brynary.com
Quacks like ActiveRecord::Base
       •   new(attributes)               •   delete(id_or_array)

       •   create(attributes)            •   delete_all

       •   create!(attributes)           •   update(ids, updates)

       •   find(id_or_array)              •   update_all(updates)

       •   destroy(id_or_array)          •   exists?

       •   destroy_all



Arel           http://bit.ly/ggrc-arel         brynary              brynary.com
Example

   class
Rubyist
   

scope
:nycrb,
where(:city
=>
"NYC")
   end




Arel      http://bit.ly/ggrc-arel     brynary   brynary.com
Example

 class
Rubyist
 

self.scope(:nycrb,
self.where(:city
=>
"NYC"))
 end




Arel      http://bit.ly/ggrc-arel     brynary   brynary.com
Example

       Rubyist.scope
:nycrb,

       

Rubyist.where(:city
=>
"NYC")




Arel       http://bit.ly/ggrc-arel     brynary   brynary.com
Example

nycrb
=
Rubyist.where(:city
=>
"NYC")
Rubyist.scope
:nycrb,
nycrb




Arel   http://bit.ly/ggrc-arel     brynary   brynary.com
def
self.scope(name,
scope_options
=
{},
&block)


name
=
name.to_sym


valid_scope_name?(name)



extension
=
Module.new(&block)
if
block_given?



scopes[name]
=
lambda
do
|*args|




options
=
scope_options.is_a?(Proc)
?
scope_options.call(*args)
:
scope_options





relation
=
if
options.is_a?(Hash)






scoped.apply_finder_options(options)




elsif
options






scoped.merge(options)




else






scoped




end





extension
?
relation.extending(extension)
:
relation


end



singleton_class.send(:redefine_method,
name,
&scopes[name])
end



Arel              http://bit.ly/ggrc-arel          brynary               brynary.com
def
self.scope(name,
scope_options
=
{})
 

name
=
name.to_sym
 

valid_scope_name?(name)

 

scopes[name]
=
lambda
do
|*args|
 



if
scope_options.is_a?(Hash)
 





scoped.apply_finder_options(scope_options)
 



elsif
scope_options
 





scoped.merge(scope_options)
 



else
 





scoped
 



end
 

end

 

singleton_class.send(:redefine_method,
name,
&scopes[name])
 end



Arel         http://bit.ly/ggrc-arel   brynary          brynary.com
def
self.scope(name,
scope_options
=
{})
 

name
=
name.to_sym
 

valid_scope_name?(name)

 

scopes[name]
=
lambda
do
|*args|
 



scoped.merge(scope_options)
 

end

 

singleton_class.send(:redefine_method,
name,
&scopes[name])
 end




Arel         http://bit.ly/ggrc-arel   brynary          brynary.com
def
self.scope(name,
scope_options
=
{})
 

name
=
name.to_sym
 

valid_scope_name?(name)

 

scopes[name]
=
lambda
do
|*args|
 



scoped.merge(scope_options)
 

end

 

singleton_class.send(:redefine_method,
name,
&scopes[name])
 end




Arel         http://bit.ly/ggrc-arel   brynary          brynary.com
def
self.scope(name,
scope_options
=
{})
 

name
=
name.to_sym
 

valid_scope_name?(name)

 

scopes[name]
=
lambda
do
|*args|
 



scoped.merge(scope_options)
 

end

 

singleton_class.send(:redefine_method,
name,
&scopes[name])
 end




Arel         http://bit.ly/ggrc-arel   brynary          brynary.com
class
Rubyist
       

def
self.nycrb
       



where(:city
=>
"NYC")
       

end
       end




Arel     http://bit.ly/ggrc-arel   brynary   brynary.com
Arel Under the Hood




Arel     http://bit.ly/ggrc-arel   brynary   brynary.com
Arel Objects
   City.arel_table
   #
=>
<Arel::Table>

   City.arel_table[:population]
   #
=>
<Arel::Sql::Attributes::Integer
population>

   City.arel_table[:population].gt(750_000)
   #=>
<Arel::Predicates::GreaterThan>




Arel        http://bit.ly/ggrc-arel   brynary    brynary.com
Exposing the Attributes

       class
ActiveRecord::Base
       

def
self.[](column_name)
       



arel_table[column_name]
       

end
       end



Arel      http://bit.ly/ggrc-arel   brynary   brynary.com
Arel Predicates

  City.where(City[:population].gt(750_000))




Arel     http://bit.ly/ggrc-arel   brynary   brynary.com
Arel Operators
       • eq                           • matches
       • not_eq                       • not_matches
       • lt                           • in
       • lteq                         • not_in
       • gt                           • *_any
       • gteq                         • *_all
Arel        http://bit.ly/ggrc-arel       brynary     brynary.com
Compound Predicates
   hometown

=
City[:name].eq("Detroit")
   big






=
City[:population].gt(750_000)
   awesome


=
City[:awesome].eq(true)

   City.where(hometown.or(big.and(awesome))).to_sql
   #
=>
SELECT
*
FROM
cities
   




WHERE
name
=
'Detroit'
   







OR
(population
>
750000
AND
awesome
=
't')




Arel        http://bit.ly/ggrc-arel   brynary    brynary.com
Future
       Possibilities
                 `
       ActiveRecord 3.1? 4.0?




Arel          http://bit.ly/ggrc-arel   brynary   brynary.com
Map any relation to a class
       class
Signup
<
ActiveRecord::Base
       

users
=
Arel::Table.new(:users)
       

emails
=
Arel::Table.new(:emails)

       

set_relation
users_table.
       



join(emails).
       



on(users[:email_id].eq(emails[:id]))
       end




Arel        http://bit.ly/ggrc-arel   brynary   brynary.com
May any relation as an association
       class
User
       

orders
=
Arel::Table.new(:orders)

       

last_orders_by_user
=
orders.
       



group(orders[:user_id]).
       



project(orders[:id].maximum.as(:id))

       

has_one
:last_order,
orders.
       



where(orders[:id].in(last_orders_by_user[:id]))
       end

       User.includes(:last_order).each
do
|user|
       

#
...
       end
Arel            http://bit.ly/ggrc-arel   brynary     brynary.com
Custom Engines



Arel   http://bit.ly/ggrc-arel   brynary   brynary.com
ActiveRecord 3

                                 Arel

          Algebra                       Engines


         AR Connection Adapters

                           SQL Database

Arel   http://bit.ly/ggrc-arel          brynary   brynary.com
ActiveRecord 3

                                 Arel

          Algebra                       Engines


         AR Connection Adapters

                           SQL Database

Arel   http://bit.ly/ggrc-arel          brynary   brynary.com
ActiveRecord 3

                                 Arel

          Algebra                       Engines


         AR Connection Adapters

                           SQL Database

Arel   http://bit.ly/ggrc-arel          brynary   brynary.com
ActiveRecord 3

                                 Arel
                                               Engines
          Algebra                       SQL             Memory




         AR Connection Adapters

                           SQL Database

Arel   http://bit.ly/ggrc-arel                brynary            brynary.com




class
Arel::Sql::Engine






def
initialize(ar
=
nil)








@ar
=
ar






end







def
connection








@ar
?
@ar.connection
:
nil






end







def
create(relation)








#
...








connection.insert(relation.to_sql(false),
nil,
relation.primary_key)






end







def
read(relation)








rows
=
connection.select_rows(relation.to_sql)








Array.new(rows,
relation.attributes)






end







def
update(relation)








connection.update(relation.to_sql)






end







def
delete(relation)








connection.delete(relation.to_sql)






end




end
 Arel              http://bit.ly/ggrc-arel          brynary               brynary.com
Possible Arel Engines

       • NoSQL (e.g. Redis, CouchDB)
       • Memcache
       • Web service APIs (e.g. AWS, Twitter)
       • File system

Arel        http://bit.ly/ggrc-arel   brynary   brynary.com
Cross-Engine Joins



Arel   http://bit.ly/ggrc-arel   brynary   brynary.com
Thank You



Arel   http://bit.ly/ggrc-arel   brynary   brynary.com

Weitere ähnliche Inhalte

Ähnlich wie Arel: Introduction to the Ruby Relational Algebra Library

Griffith uni
Griffith uniGriffith uni
Griffith uninigel99
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Wen-Tien Chang
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage ServerLin Jen-Shin
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Ecossistema Ruby - versão SCTI UNF 2013
Ecossistema Ruby - versão SCTI UNF 2013Ecossistema Ruby - versão SCTI UNF 2013
Ecossistema Ruby - versão SCTI UNF 2013Fabio Akita
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails_zaMmer_
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails_zaMmer_
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails BootcampMat Schaffer
 
O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?Fabio Akita
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large GraphsNishant Gandhi
 
Adding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of TricksAdding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of Trickssiculars
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Railstielefeld
 
Lessons Learnt From Working With Rails
Lessons Learnt From Working With RailsLessons Learnt From Working With Rails
Lessons Learnt From Working With Railsmartinbtt
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersJonathan Sharp
 
Socket applications
Socket applicationsSocket applications
Socket applicationsJoão Moura
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launchedMat Schaffer
 

Ähnlich wie Arel: Introduction to the Ruby Relational Algebra Library (20)

Griffith uni
Griffith uniGriffith uni
Griffith uni
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Ecossistema Ruby - versão SCTI UNF 2013
Ecossistema Ruby - versão SCTI UNF 2013Ecossistema Ruby - versão SCTI UNF 2013
Ecossistema Ruby - versão SCTI UNF 2013
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
 
Jasig rubyon rails
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
 
PTW Rails Bootcamp
PTW Rails BootcampPTW Rails Bootcamp
PTW Rails Bootcamp
 
O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?O que tem de novo no Ruby 2.0?
O que tem de novo no Ruby 2.0?
 
Processing Large Graphs
Processing Large GraphsProcessing Large Graphs
Processing Large Graphs
 
Adding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of TricksAdding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of Tricks
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Rails
 
Lessons Learnt From Working With Rails
Lessons Learnt From Working With RailsLessons Learnt From Working With Rails
Lessons Learnt From Working With Rails
 
Stack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for DevelopersStack Overflow Austin - jQuery for Developers
Stack Overflow Austin - jQuery for Developers
 
Bhavesh ro r
Bhavesh ro rBhavesh ro r
Bhavesh ro r
 
Rack
RackRack
Rack
 
Socket applications
Socket applicationsSocket applications
Socket applications
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launched
 

Kürzlich hochgeladen

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
#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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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 ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 

Arel: Introduction to the Ruby Relational Algebra Library

Hinweis der Redaktion

  1. How many people have heard of Arel?
  2. Lots of contributors!!!
  3. Math concept. Offshoot of set theory. E.F. Codd in 1970 You use relation algebra when you use SQL.
  4. Header with columns and types.
  5. A set of tuples. Not SQL specific. ...But: think about tables, views, query results ...in AR: classes, associations
  6. Selection: WHERE (restrict a set)
  7. Projection: Limit the columns (SELECT ...)
  8. Like SQL
  9. Set operations
  10. Operations on relations yield new relations. Implemented in code as the composite pattern. Note: This works because relations are immutable, which is cool.
  11. Cleaned up ActiveRecord. Nice new Syntax for you.
  12. Query runs on iteration
  13. Cleans up everything quite nicely
  14. Caution! Not supported by Rails. Don&amp;#x2019;t report bugs ;-) Subject to Arel API changes
  15. Contrived example. Consider your code that builds queries based on data.
  16. AR becomes a Data Mapper
  17. Arel is split into Algebra and Engines
  18. Arel supports multiple engines
  19. Each engine defines CRUD operations
  20. Write an ActiveRecord relation that pulls IDs from Redis and records from a table