[Dbix-class] inheritance

Hermida, Leandro Leandro.Hermida at fmi.ch
Wed Sep 13 13:42:26 CEST 2006


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
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060913/e54cf837/attachment.htm 


More information about the Dbix-class mailing list