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

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Kürzlich hochgeladen (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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