Module: ActiveRecord

Defined in:
lib/active_record/connection_adapters/hyper_table_definition.rb,
lib/hyper_record.rb,
lib/associations/hyper_has_many_association_extension.rb,
lib/active_record/connection_adapters/qualified_column.rb,
lib/active_record/connection_adapters/hypertable_adapter.rb,
lib/associations/hyper_has_and_belongs_to_many_association_extension.rb

Overview

Since Hypertable does not support join within queries, the association information is written to each table using qualified columns instead of using a separate JOIN table (as is the case for has_and_belongs_to_many associations in a regular RDBMS).

For instance, assume that you have two models (Book and Author) in a has_and_belongs_to_many association. The HABTM association in a traditional RDBMS requires a join table (authors_books) to record the associations between objects. In Hypertable, instead of using a separate join table, each table has a column dedicated to recording the associations. Specifically, the books table has an author_id column and the authors table has a book_id column.

Column qualifiers are used so we can record as many associated objects are necessary. If an Author with the row key charles_dickens is added to a Book with the row key tale_of_two_cities, then a cell called author_id:charles_dickens is added to the Book object and a cell called book_id:tale_of_two_cities is added to the Author object. The value of the cells is inconsequential - their presence alone indicates an association between the objects.

When an object in an HABTM association is destroyed, the corresponding entries in the associated table are removed (warning: don’t use delete because it will leave behind stale association information)

Defined Under Namespace

Modules: Associations, ConnectionAdapters Classes: Base, HyperBase