Me
About
Gallery
Company
Girl


Projects
Ruby on Rails
Basecamp
Highrise
Backpack
Campfire
Ta-da List
Writeboard


More
Feed
Archives

October 29, 11:44

No tightly coupling with DBMs in Active Record

Hi Matt. Thanks for the kind words. I'm honored. I'd just like to correct one misconception about Rails.

When you write "something like Rails would never fly in Java because it appears to be tightly coupled to the database" that's not really true. Active Record (the ORM part of Rails) has a database abstraction layer embedded called Abstract Adapter, which all the specific adapters are implementing transparently.

Hence, your Rails application is not tightly coupled to a specific database, but rather to the Abstract Adapter interface. Since concrete adapters are just ~100 lines of code, it's pretty easy to implement your own adapter if the current offering isn't sufficient.

The PostgreSQL and SQLite adapters were implemented one the same day by one person (Luke Holden). There's a Microsoft SQL Server adapter just around the corner (by Joey Gibson) and I've heard of people working on Oracle and DB2 adapters too.

So the only tightly coupling going on is if you write database-specific SQL. On that account, I'm actually very sympathetic to Jeremy Zawodny's Database Abstraction Layers Must Die!. Chasing database abstraction without a specific business case asking for it is just something You're Not Gonna Need and it's certainly not doing The Simplest Thing Possible.


Challenge by klaus momberger on October 30, 14:09

I tried an Oracle Adapter, but put it on hold when I realized that active-record is using MySQL features not supported by Oracle (the LIMIT clause, particularly) . DB2 doesn't support it either, as far as I remember.

-klaus

Challenge by David Heinemeier Hansson on October 30, 14:12

LIMIT is mostly used as a performance optimization for finders such as find_first (that will only return 1 object, so pulling more rows would be silly) and occasionally specified as a parameter by the user. The latter could easily be solved by implementing the same behavior in the adapter itself.

So if LIMT 5,10 is called, you fetch the entire result set and do results[4...10] to archive the same effect.

Challenge by Will Drewry on October 30, 19:22

Re: tight coupling to the database

People can write ActiveRecord knock-offs that just ducktype with ActiveRecord, e.g. ActiveFS, ActiveNIS. Making a stand in for ActiveRecord isn't impossible at all and means that you aren't necessarily tied to any specific backend. Abstract adapters make it at least one hundred times easier though!

-wad

Challenge by David Heinemeier Hansson on October 30, 19:23

Right. One project is already doing just that: ActiveLDAP.

Challenge by Morten on October 31, 13:28

In Oracle you can use ROWNUM to implement LIMIT functionality.

Challenge by klaus momberger on October 31, 20:46

ROWNUM is irrelevant if you have an "order by", in this case you have
to use row_number() which is not generic. I know that active record can be ported to Oracle, but it is somewhat "tightly coupled" by its SQL dialect.

Challenge by Morten on October 31, 22:34

Lots of ways for making ROWNUM work with ORDER BY can be seen at: http://www.adp-gmbh.ch/ora/sql/examples/first_rows.html

Anyway - I don't know what the exact problem is, so I may be miles off..

Challenge by klaus momberger on October 31, 23:07

Nope, you are not, the page even mentions row_number(). ;-)

Challenge by 2005 problem gambling conferences on May 09, 0:02

You may find it interesting to check some relevant pages dedicated to blackjack blackjack http://www.juris-net.com/blackjack.html black jack online black jack online http://www.juris-net.com/black-jack-online.html mississippi casinos mississippi casinos http://www.juris-net.com/mississippi-casinos.html blackjack tips blackjack tips http://www.juris-net.com/blackjack-tips.html clay poker chip sets clay poker chip sets http://www.juris-net.com/clay-poker-chip-sets.html seneca niagara casino seneca niagara casino http://www.juris-net.com/seneca-niagara-casino.html computer poker game computer poker game http://www.juris-net.com/computer-poker-game.html real poker chips real poker chips http://www.juris-net.com/real-poker-chips.html tropicana casino atlantic city tropicana casino atlantic city http://www.juris-net.com/tropicana-casino-atlantic-city.html gambling specials gambling specials http://www.juris-net.com/gambling-specials.html biloxi ms casinos biloxi ms casinos http://www.juris-net.com/biloxi-ms-casinos.html strip poker video strip poker video http://www.juris-net.com/strip-poker-video.html oneida casino oneida casino http://www.juris-net.com/oneida-casino.html play poker like the pros play poker like the pros http://www.juris-net.com/play-poker-like-the-pros.html vegas slot machines for sale vegas slot machines for sale http://www.juris-net.com/vegas-slot-machines-for-sale.html gambling game gambling game http://www.juris-net.com/gambling-game.html gambling history gambling history http://www.juris-net.com/gambling-history.html loose slot online loose slot online http://www.juris-net.com/loose-slot-online.html blackjack tables for sale blackjack tables for sale http://www.juris-net.com/blackjack-tables-for-sale.html blackjack avion for sale blackjack avion for sale http://www.juris-net.com/blackjack-avion-for-sale.html restaurant economic development gambling restaurant economic development gambling http://www.juris-net.com/restaurant-economic-development-gambling.html uk gambling uk gambling http://www.juris-net.com/uk-gambling.html reel deal slots reel deal slots http://www.juris-net.com/reel-deal-slots.html gambling times gambling times http://www.juris-net.com/gambling-times.html free blackjack 21 cash casino free blackjack 21 cash casino http://www.juris-net.com/free-blackjack-21-cash-casino.html cheaters guide blackjack cheaters guide blackjack http://www.juris-net.com/cheaters-guide-blackjack.html sex roulette sex roulette http://www.juris-net.com/sex-roulette.html blackjack and carburetor blackjack and carburetor http://www.juris-net.com/blackjack-and-carburetor.html black jack betting techniques black jack betting techniques http://www.juris-net.com/black-jack-betting-techniques.html video keno chat video keno chat http://www.juris-net.com/video-keno-chat.html russian roulette history russian roulette history http://www.juris-net.com/russian-roulette-history.html shock roulette shock roulette http://www.juris-net.com/shock-roulette.html the odds of winning black jack the odds of winning black jack http://www.juris-net.com/the-odds-of-winning-black-jack.html calculate the odds of winning at keno calculate the odds of winning at keno http://www.juris-net.com/calculate-the-odds-of-winning-at-keno.html combination pool table ping pong roulette table combination pool table ping pong roulette table http://www.juris-net.com/combination-pool-table-ping-pong-roulette-table.html - Tons of interesdting stuff!!!

Challenge by internet casino on June 22, 6:41

You are invited to visit some relevant pages about internet casino internet casino http://www.scottishtutors.com/internet-casino.html ... Thanks!!!