Excuse me for asking off topic (and stupid), I am just learning to use
Entity Beans on Orion.

In most tutorials entity beans only represent ONE ROW from ONE TABLE, but
relational databases go far beyond that.

I have a relational database for movies, actors, directors & writers.

So I have a table tblMovies
INT id, VARCHAR title, INT year, VARCHAR description
e.g.:
1, 'Casablanca',1942,'the classical movie'
2, 'The Maltese Falcon',1946,'begin of the dark series'
3, 'The Seawulf',1947,'after the novel from Jack London'
...

I have a tblActors (INT id, VARCHAR name)
1,'Humphrey Bogart'
2,'Ingrid Bergman'
3,'Edward G. Robinson'
...

and in the same manner tblDirectors, tblWriters

And I have tables for the relations, e.g.

tblRoles (INT filmid, INT actorid)
1,1
2,1
1,2
3,3
..
and also tblMisEnScene, tblScreenplay

meaning: Humphrey Bogart (actorid: 1) appeared in 'Casablanca' (filmid: 1)
and 'The Maltese Falcon' (filmid: 2), Ingrid Bergman (actorid: 2) appeared
in 'Casablanca' (filmid: 1), Edward G. Robinson (actorid: 3) appeared in
'The Seawulf' (filmid: 3) . So this relational structure allows that one
film can have multiple actors, writers, directors and one actor can appear
in multiple films. Relational basework, of course.

If I want to extract those films in which Humphrey Bogart appeared I can do
this easily in SQL (used by a Servlet) with:

SELECT title FROM tblFilms WHERE id IN (SELECT filmid FROM tblRoles WHERE
actorid=(SELECT id FROM tblActors WHERE name='Humphrey Bogart'))

(or as in my case with JOINS from MySQL)

When I do want to write an EJB-Application using this database, how do I do
this ? How do I represent the relational data ?

Do I have to keep Entity Beans for EVERY row of ANY table ? Do I have to
create temporary tables with all information merged ? This creates a problem
because one film can have one or more writers (Casablanca had three) and (in
most cases) more than one actor.

This way  ?

public class MovieBean implements javax.ejb.EntityBean
    {
    String Title;
    String[] Actors;
    ...
    public String getTitle() throws RemoteException;
        {...
        }
    public String[] getActors() throws RemoteException;
        {
        return Actors[];
        }
    }

using Arrays filled from the database with all actors, directors, writers ?

Please give me a hint ! (Well, I know I am stupid. But it is a good work to
help stupid persons)


Maximilian Eberl
http://www.derdickemax.de
mailto:[EMAIL PROTECTED]




Reply via email to