Skip to content

Instantly share code, notes, and snippets.

@rtirrell
Created June 29, 2010 22:40
Show Gist options
  • Select an option

  • Save rtirrell/457934 to your computer and use it in GitHub Desktop.

Select an option

Save rtirrell/457934 to your computer and use it in GitHub Desktop.
INFO = <<HERE
TABLES:
gds
- key gds
gse
- key gse
gds_gse
- key gds
- int gse
a GDS has 1 GSE, and a GSE belongs to one GDS (through GDS_GSE, so apparently I ought to use a has 1 relationship). How can I write this? I've been entirely unable to figue it out.
HERE
class GDS
include DataMapper::Resource
def self.default_repository_name; :expr_geo; end
storage_names[:expr_geo] = "gds"
property :gds, Integer, :key => true
has 1, :gse, "GSE", :child_key => [:gse], :parent_key => [:gds], :through => GDSGSE
class GDSGSE
include DataMapper::Resource
def self.default_repository_name; :expr_geo; end
storage_names[:expr_geo] = "gds_gse"
belongs_to :gds, "GDS", :child_key => [:gds], :parent_key => [:gds], :key => true
has 1, :gse, "GSE", :child_key => [:gse], :parent_key => [:gse]
end
class GSE# < GEO
include DataMapper::Resource
def self.default_repository_name; :expr_geo; end
storage_names[:expr_geo] = "gse"
has 1, :gds, "GDS", :through => :gds_gse, :child_key => [:gse], :parent_key => [:gds], :key => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment