Note of Kodo JDONote >>
<< 增加修改粘贴板中…
Consistency of inhe…

Author Zhou Renjian Create@ 2004-01-30 01:04
whizz Note icon

Consistency of inheritance and DB schema

I have the tables created by following SQL.
[SQL]
create table content (
 id int not null auto_increment,
 userid int references user (id),
 typeid int references type (id),
 createtime datetime not null,
 lastmodify datetime not null,
 name text not null,
 xhtml text not null,
 primary key(id)
);
create table simpletext (
 id int not null references content (id),
 content text not null,
 xml text not null,
 primary key(id)
);
create table titletext (
 id int not null references content (id),
 title text not null,
 content text not null,
 xml text not null,
 primary key(id) 
);
[/SQL]
The Java classes' relationship is:
[CODE]
SimpleText extends Content;
TitleText extends Content;
...
[/CODE]
Actually there are some more other classes extends the Content, which are to be designed on the demand in the future.
The table "content" has the basic attributes that I am going to visit frequently, and the table "simpletext" or "titletext" contains the extra infos.

That is to say, the "content" contains some fixed fundamental attributes that I can code some codes which need no furthre changes, despite of the upcoming new-designed tables. Some new Java codes and their new class for the new tables will be a  plug-in then.

So I think the "simpletext" and "titletext" should have a common "content" and their own separate tables.

But I doubt it difficult or impossible for the JDO's implementation to fulfill the task. I just had taken the [URL=http://jdocentral.com/BinSun_Tutorial.html]Bin Sun's JDO Genie Tutorial [/URL], and  found that Reply and Topic which extend from the Post are combined into ONE table "post".

But I won't like to see that all the tables to be combined in ONE table in my project.

So what is up to the my problem? Is it my database schema unpractical, or are there some tables-mapping mechanism should be used?

Thanks

本记录所在类别:
本记录相关记录: