Chapter 14. Bidirectional Associations Practice Projects

Table of Contents

1. Assign directors/actors to movies and movies to directors/actors
2. Assign cities to a country and members to an organization, and vice versa

All projects include the following tasks:

  1. Make an OO class model derived from the given information design model. Hint: replace associations with corresponding reference properties.

  2. Make a JavaScript class model or a Java Entity class model derived from the OO class model. Hint: add check and setter methods.

  3. Code your JavaScript class model or Java Entity class model, following the provided guidelines.

Make sure that your pages comply with the XML syntax of HTML5, and that your JavaScript code complies with our Coding Guidelines and is checked with JSHint (http://www.jshint.com).

1. Assign directors/actors to movies and movies to directors/actors

This project is based on the information design model below. The app from the previous assignment is to be extended by adding derived inverse reference properties for implementing the bidirectional associations. This is achieved by adding the multi-valued reference properties directedMovies and playedMovies to the model class Person, both with range Movie.

You can use the following sample data for testing your app:

Movies
Movie ID Title Release date Director Actors
1 Pulp Fiction 1994-05-12 1 5, 6
2 Dangerous Liaisons 1988-12-16 2 7, 5
3 Inglourious Basterds 2009-05-20 1 9, 1
People
Person ID Name Directed movies Played movies
1 Quentin Tarantino 1, 3 3
2 Stephen Frears 2
5 Uma Thurman 1, 2
6 John Travolta 1
7 Keanu Reeves 2
9 Brad Pitt 3

More movie data can be found at the IMDb website.