Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update README and example

  • Loading branch information...
commit 7865350d5d043c0e7b8c1d676e974dfa620371c7 1 parent 9117358
@delitescere authored
Showing with 12 additions and 3 deletions.
  1. +10 −1 README.md
  2. +2 −2 lib/example_squeal.rb
View
11 README.md
@@ -9,6 +9,15 @@ To run standalone, simply make your data squeal thusly:
where the squeal script includes a `require 'squealer'`.
+## Rationale
+* For some reason cranky old data guys think Coad was the first person to invent a data modelling paradigm
+* Josh Graham is crankier and in many cases older (although much better looking) than your cranky old DBA, so he remembers when there were no Relational Databases around, and one had to construct queries that explicitly traversed the network or hierarchical databases of the time (or even the indexed file systems). CODASYL, can you spell it?
+* Although many business problems are best expressed in terms of a spreadsheet (a tuple space), and despite the somewhat disturbing fact that the majority of the world's critical commercial systems hinge on Excel spreadsheets, not every problem is best modelled this way
+* MongoDB (along with a growing number of other "Not only SQL" databases) provides an alternate mechanism to store data in a way that naturally reflects the real-world problem. Simpler application code, higher performance and straight-forward scalabiltity are natural benefits of modelling in a way that most closely reflects reality
+* At the inaugural QCon San Francisco in a discussion with Martin Fowler and Ola Bini, Josh postulated that ORMs had it the wrong way around: that the application should be persisting its data in a manner natural to it, and that external systems (like reporting and decision support systems - or even numbskull integration at the persistence layer) should bear the cost of mapping. With the huge efforts put into noSQL engines like MongoDB, neo4j, Redis, Hadoop, CouchDB, Memcached, et cetera, has come a rise in popularity. With this increased and broader usage comes people who are looking for tools to make these data stores more accessible. The application is no longer bearing the cost of mapping - it's now time for the ancillary and external systems to pick up the bill!
+* squealer provides a simple, declarative language for mapping values from trees into relations. It is inherently flexibile by being an internal Ruby DSL, so any imperative traversal or mapping logic can be expressed
+* It can be used both in bulk operations on many documents (e.g. a periodic batch job) or executed for one document asynchronously as part of an after_save method (e.g. via a Resque job). It is possible that more work may done on this event-driven approach, perhaps in the form of a squealerd, to reduce latency.
+
## Release Notes
### v2.1
* Ruby 1.8.6 back-compatibility added. Using `eval "", binding, __FILE__, __LINE__` instead of `binding.eval`
@@ -40,7 +49,7 @@ Squealer is for _standalone_ operation. DO NOT use it directly from within your
* `TrueClass#to_i` - You'll be storing booleans as a `tinyint(1)`, or similar. `true` is `1`.
## It is a data mapper, it doesn't use one.
-Squealer doesn't use your application classes. It doesn't use your ActiveRecord models. It doesn't use mongoid (as awesome as that is), or mongomapper. It's an ETL tool. It could even be called a HRM (Hashmap-Relational-Mapper), but only in hushed tones in the corner boothes of dark pubs. It directly uses the Ruby driver for MongoDB and the Ruby driver for mySQL.
+Squealer doesn't use your application classes. It doesn't use your ActiveRecord models. It doesn't use mongoid (as awesome as that is), mongodoc, or mongomapper. It's an ETL tool. It could even be called a HRM (Hashmap-Relational-Mapper), but only in hushed tones in the corner boothes of dark pubs. It directly uses the Ruby driver for MongoDB and the Ruby driver for mySQL.
## Databases supported
For now, this is specifically for _MongoDB_ exporting to _mySQL_.
View
4 lib/example_squeal.rb
@@ -41,7 +41,7 @@
# You can normalize the export...
# home_address and work_address are a formatted string like: "661 W Lake St, Suite 3NE, Chicago IL, 60611, USA"
addresses = []
- addresses << atomize_address(user.home_address)
+ addresses << atomize_address(user.home_address) # atomize_address is some custom method of yours
addresses << atomize_address(user.work_address)
addresses.each do |address|
target(:address) do
@@ -55,7 +55,7 @@
#
# You can denormalize the export...
# user.home_address = { street: '661 W Lake St', city: 'Chicago', state: 'IL' }
- assign(:home_address) { flatten_address(user.home_address) }
+ assign(:home_address) { flatten_address(user.home_address) } # flatten_address is some custom method of yours
assign(:work_address) { flatten_address(user.work_address) }
user.activities.each do |activity|
Please sign in to comment.
Something went wrong with that request. Please try again.