[Dbix-class] combining tables

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Thu Jun 17 13:56:10 GMT 2010


Is there way to present a merged view of some tables using DBIx::Class?

Imagine I have three tables:

pig (
    pig_id    INT,
    pig_name  TEXT,
    colour    ENUM ('brown', 'black', 'white),
);

cow (
    cow_id    INT,
    cow_name  TEXT,
    colour    ENUM ('brown', 'black', 'white),
);

sheep (
    sheep_id    INT,
    sheep_name  TEXT,
    colour      ENUM ('brown', 'black', 'white),
);

What's more, the values of pig_id, cow_id and sheep_id are disjoint.

I'd like DBIC to present them as though they were a single table

animal (
    id      INT,
    name    TEXT,
    colour  ENUM ('brown', 'black', 'white),
);

Is there some way to do that?

Thanks, Dave



More information about the DBIx-Class mailing list