STI and through


I’m trying to understand how to do the following, but am finding myself

I have three main tables; here are the first two:

CREATE TABLE reference_items (
“id” integer primary key,
“type” varchar(20),
“title” varchar(255),
“year” year(4)

CREATE TABLE “agents” (
“id” integer primary key,
“type” varchar(20),
“sort_name” varchar(255),
“description” text

So I’ve got ReferenceItem and Agent classes, each of which has
subclasses (for
the first, stuff like Book, Article, etc.).

The third key table links the above:

CREATE TABLE contributors (
“reference_item_id” integer,
“agent_id” integer,
“position” integer,
“type” varchar(20)

The Contributor class currently has four subclasses: Author, Editor,
and Translator. So the idea is I need to be able to separely track the
type and
order of each class.

So how do I get this correctly setup in my models? Or can I?