Here are my tables. Note that I'm missing the Innodb setting and I believe I want that. I'm using MySQL 4.0.20. If I was writing these create scripts by hand I would tak on a FOREIGN KEY with "ON DELETE CASCADE", but I don't know how to get Hibernate to do that.
Thanks for you help!
Don
Code:
create table Categories (
CategoryID BIGINT NOT NULL AUTO_INCREMENT,
Name VARCHAR(128) not null,
CategoryType CHAR(1) not null,
LastModDate DATETIME not null,
ParentID BIGINT,
primary key (CategoryID),
unique (Name, CategoryType)
);
create table CategoryTerms (
CategoryID BIGINT not null,
TermID BIGINT not null,
primary key (TermID, CategoryID),
unique (TermID, CategoryID)
);
create table Terms (
TermID BIGINT NOT NULL AUTO_INCREMENT,
Term VARCHAR(255) not null,
LastModDate DATETIME not null,
primary key (TermID),
unique (Term)
);
alter table Categories add index FKC419223C49E5F365 (ParentID), add constraint FKC419223C49E5F365 foreign key (ParentID) references Categories (CategoryID);
alter table CategoryTerms add index FK43303B09951BCEA7 (TermID), add constraint FK43303B09951BCEA7 foreign key (TermID) references Terms (TermID);
alter table CategoryTerms add index FK43303B09C4195AB9 (CategoryID), add constraint FK43303B09C4195AB9 foreign key (CategoryID) references Categories (CategoryID);