SlideShare a Scribd company logo
1 of 15
Download to read offline
SchemaPlus
enhanced capabilities for schema definition and querying
          Ronen Barzel & Michał Łomnicki
History
Simon Harris / harukizaemon

redhillonrails_core (2006, 2009)

foreign_key_migrations => automatic_foreign_key

schema_plus (2011)
Goals
solid base

well-tested

well-documented

better name :)
Plain ActiveRecord
create_table :comments do |t|
    t.text :body
    t.integer :post_id
    t.integer :author_id
end
execute "ALTER TABLE comments ADD FOREIGN KEY (post_id) 
    REFERENCES (posts)"
execute "ALTER TABLE comments ADD FOREIGN KEY (author_id) 
    REFERENCES (users)"
add_index :comments, :post_id
With schema_plus
create_table :comments do |t|
    t.text :body
    t.integer :post_id, :index => true
    t.integer :author_id, :references => :users
end
auto-index foreign keys
# without auto_index
t.integer :post_id, :index => true
# with auto_index
t.integer :post_id
index
t.string :area_code
t.string :local_number,
     :index => { :unique => true, :with => :area_code }
Other features
global, per table and per statement config

expressional indexes

views
SchemaAssociations
# without schema_associations
class Post < ActiveRecord::Base
    belongs_to :author
    has_many :comments
end
SchemaAssociations
# without schema_associations
class Post < ActiveRecord::Base
    # associations auto-created from foreign keys
end
SchemaValidations
create_table :posts do |t|
    t.integer :author_id, :null => false, :references => :users
    t.integer :likes_count
    t.string :content, :limit => 5_000
end
SchemaValidations
# without schema_validations
class Post < ActiveRecord::Base
    validates :author, :presence => true
    validates :likes_count, :numericality => true
    validates :content, :length => { :maximum => 5_000 }
end
SchemaValidations
# with schema_validations
class Post < ActiveRecord::Base
end
Schema Family
Scary?

...but that's next step for active record pattern
Questions
http://github.com/lomba

More Related Content

Viewers also liked (7)

ACID - Transakcje
ACID - TransakcjeACID - Transakcje
ACID - Transakcje
 
Nodejs + Rails
Nodejs + RailsNodejs + Rails
Nodejs + Rails
 
Having fun with legacy apps
Having fun with legacy appsHaving fun with legacy apps
Having fun with legacy apps
 
Ruby tricks2
Ruby tricks2Ruby tricks2
Ruby tricks2
 
DDD, Rails and persistence
DDD, Rails and persistenceDDD, Rails and persistence
DDD, Rails and persistence
 
Cap Theorem
Cap TheoremCap Theorem
Cap Theorem
 
Tradycyjne indeksy w sql server
Tradycyjne indeksy w sql serverTradycyjne indeksy w sql server
Tradycyjne indeksy w sql server
 

Similar to Schema plus

Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModel
pauldix
 
Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModel
pauldix
 

Similar to Schema plus (20)

Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecord
 
Ruby on rails3 - introduction to rails
Ruby on rails3 - introduction to railsRuby on rails3 - introduction to rails
Ruby on rails3 - introduction to rails
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
 
Valeriy Prokopchuk: Validators in Migrations.
Valeriy Prokopchuk: Validators in Migrations.Valeriy Prokopchuk: Validators in Migrations.
Valeriy Prokopchuk: Validators in Migrations.
 
PostgreSQL Materialized Views with Active Record
PostgreSQL Materialized Views with Active RecordPostgreSQL Materialized Views with Active Record
PostgreSQL Materialized Views with Active Record
 
SF Elixir Meetup - RethinkDB
SF Elixir Meetup - RethinkDBSF Elixir Meetup - RethinkDB
SF Elixir Meetup - RethinkDB
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Sequel
SequelSequel
Sequel
 
Data Integrity in Rails
Data Integrity in RailsData Integrity in Rails
Data Integrity in Rails
 
Merb Router
Merb RouterMerb Router
Merb Router
 
Rspec API Documentation
Rspec API DocumentationRspec API Documentation
Rspec API Documentation
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflow
 
Html css
Html cssHtml css
Html css
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schema
 
MongoDb
MongoDbMongoDb
MongoDb
 
Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModel
 
Building Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModelBuilding Web Service Clients with ActiveModel
Building Web Service Clients with ActiveModel
 
The Ring programming language version 1.2 book - Part 33 of 84
The Ring programming language version 1.2 book - Part 33 of 84The Ring programming language version 1.2 book - Part 33 of 84
The Ring programming language version 1.2 book - Part 33 of 84
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 

Recently uploaded

Recently uploaded (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 

Schema plus