Dana Hudes:
> I'm using Postgresql.
> I'll simplify my data model (!) for a similar example. Let us say I have
> clothes and I wish to use a controlled vocabulary for color (e.g., the
> Pantone colors so that I have an exact specification of color). So of
> course the color table has the structure
> TABLE colors (
> ident SERIAL NOT NULL PRIMARY KEY,
> name VARCHAR(32) NOT NULL,
> C int2,
> M int2,
> Y int2,
> K int2
> );
>
> TABLE clothes (
> ident SERIAL NOT NULL PRIMARY KEY,
> name VARCHAR(32),
> color integer,
> designer VARCHAR(64), -- really should be a CV also but for simplicity
> FOREIGN KEY ("color") REFERENCES "colors"("name")
> );
> relationships:
> -a clothes has colors
>
Plural table names are bad bad bad!
Use id as primary key...
This is better.
TABLE color (
id SERIAL NOT NULL PRIMARY KEY,
name VARCHAR(32) NOT NULL,
C INT2,
M INT2,
Y INT2,
K INT2
);
TABLE cloth (
id SERIAL NOT NULL PRIMARY KEY,
name VARCHAR(32),
color INTEGER REFERENCES color (id),
designer VARCHAR(64)
);
You already have foreign keys in your sql, so you should let
Class::DBI::Loader setup your relationships.
Just set relationships => 1 in Maypole::Model::CDBI
-- sebastian_______________________________________________ maypole mailing list maypole at lists.netthink.co.uk http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:58 GMT