Hello,
 
I have a question about inheritance (or generalization/specialization hierarchies?) when building your classes using DBIx::Class.  If I have a data model with inheritance:
 
-- abstract class
create table parameterizable (
  id                INT NOT NULL
  ... some basic columns here...
);
 
-- abstract class
create table protocol (
  id                INT NOT NULL,
  name              VARCHAR(200)
);
 
 
create table growth_protocol (
  id                INT NOT NULL,
  medium            VARCHAR(200),
  temperature       VARCHAR(200)
);
 
create table treatment_protocol (
  id                INT NOT NULL,
  compound          VARCHAR(200),
  delivery_method   VARCHAR(200)        
);
 
 
alter table parameterizable
  ADD CONSTRAINT pk_id_01 PRIMARY KEY (id)
;
 
alter table protocol
  ADD CONSTRAINT pk_id_02 PRIMARY KEY (id)
  ADD CONSTRAINT fk_id_02 FOREIGN KEY (id) REFERENCES parameterizable (id)
;
 
alter table growth_protocol
  ADD CONSTRAINT pk_id_03 PRIMARY KEY (id)
  ADD CONSTRAINT fk_id_03 FOREIGN KEY (id) REFERENCES protocol (id)
;
 
alter table treatment_protocol
  ADD CONSTRAINT pk_id_04 PRIMARY KEY (id)
  ADD CONSTRAINT fk_id_04 FOREIGN KEY (id) REFERENCES protocol (id)
;
 
How does one represent this using DBIx::Class?  Since abstract classes like Parameterizable and Protocol should never get instantiated directly then how do I create DBIx::Class packages for GrowthProtocol and TreatmentProtocol which will transparently join with the to the abstract class tables and get the accessors when instantiating objects?
 
Thank you for your help,
 
 
Leandro Hermida
 
 
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to