SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Similar a Arel - Ruby Relational Algebra

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
 

Similar a Arel - Ruby Relational Algebra (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
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
🐬 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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.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 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Arel - Ruby Relational Algebra

Notas del editor

  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