Beanifying your movie database
Imagine you have a movie application (it isn’t making the folks at imdb.com nervous, but it works for you).
You can use it to look up a movie.
Once you have a movie, you can use it to launch the movie trailer.
You can do all kinds of searches to, say, find all sci-fi movies, or find all action movies by a specific director.
We can make beans for Movie, Trailer, and Director. But how do they map to the database? And how do they relate to one another?
Movie Table
MovieID | Title | Genre | DirectorID Notea foreign key into the Director table | Year |
---|---|---|---|---|
12 | Crouching Pixels, Hidden Mouse | Action | 42 | 2000 |
5 | The Fifth Array Element | Action | 27 | 2003 |
22 | The Return of the Bean Queen | Fantasy | 27 | 2001 |
11 | Lord of the Loops | Sci-fi | 42 | 2002 |
Director Table
DirectorID | OscarWinner | Degrees | Name |
---|---|---|---|
27 | TRUE | 3 | Jim Yingst |
42 | FALSE | 6 | Jessica Sant |
56 | FALSE | 24 | Skyler Safford |
17 | FALSE | 5 | John Dawson |
Note
Director doesn’t have a reference to his movies.
Trailer Table
TrailerID | FileName |
---|---|
12 | Crouching Pixels, Hidden Mouse Trailer |
5 | The Fifth Array Element Trailer |
22 | The Return of the Bean Queen Trailer |
11 NoteThe trailer’s primary key always matches the MovieID | Lord of the Loops Trailer |
Get Head First EJB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.