I have a "database design" problem.
I want to store article and keywords to this articles.
This is a "n to m" relationship.
I thought I can do this by putting the articles in a table, the keywords in a second and the realtionship information in a third.
T_Article:
ID | Name | Author | ...
T_Keyword:
ID | Keyword | ...
T_Rel_Article_Keyword:
ID_Article | ID_Keyword
That's a nice normalization and everythings seems fine - BUT ...
when I want to query all articles with the keyword "A" I first have to get the ID from T_Keyword.
Than I have to use this ID to find all Article-IDs to this Keyword ID in T_Rel_Article_Keyword and
than I can query the Articles in T_Article.
I can optimize this by using a view. Ok. But, I also whant to have the Information, what other keywords are related to the Article I've now queried.
I have to make again a query to T_Rel_Article_Keyword and then to T_Keyword to get this information. For each article.
This is bad.
Is there a better way to do this?
I'm working with java objects of course. So the best way would be a object database to store those objects in.
But I dont know where I can get one, an how to use and administrate such databases.
Or was it the wrong way to specify the DB structure manualy? Should I just put my objects with hibernate in a DB and let hibernate decide how to store it(is this possible?)?
How should I start?
(This is of course just a part of my "object zoo". The center of it all is a "information bundle" holding several smaller beans (like article, keyword, ...).
I just whant to get them all stored.
Atm I have serialized them and load them all on startup into a hashtable. This seams not to be a long term solution to me.)
|