Database Reference
In-Depth Information
mation stored in this table, assign unique IDs to each movie and actor within their
respective tables, and store only those IDs in the movies_actors_link table.
The resulting movie and actor tables look like this:
mysql> SELECT * FROM movies ORDER BY id;
+----+------+----------------------------+
| id | year | movie |
+----+------+----------------------------+
| 1 | 1997 | The Fifth Element |
| 2 | 1999 | The Phantom Menace |
| 3 | 2001 | The Fellowship of the Ring |
| 4 | 2005 | Kingdom of Heaven |
| 5 | 2010 | Red |
| 6 | 2011 | Unknown |
+----+------+----------------------------+
mysql> SELECT * FROM actors ORDER BY id;
+----+---------------+
| id | actor |
+----+---------------+
| 1 | Bruce Willis |
| 2 | Diane Kruger |
| 3 | Elijah Wood |
| 4 | Ewan McGregor |
| 5 | Gary Oldman |
| 6 | Helen Mirren |
| 7 | Ian Holm |
| 8 | Ian McKellen |
| 9 | Liam Neeson |
| 10 | Orlando Bloom |
+----+---------------+
The movies_actors_link table associates movies and actors as follows:
mysql> SELECT * FROM movies_actors_link ORDER BY movie_id, actor_id;
+----------+----------+
| movie_id | actor_id |
+----------+----------+
| 1 | 1 |
| 1 | 5 |
| 1 | 7 |
| 2 | 4 |
| 2 | 9 |
| 3 | 3 |
| 3 | 7 |
| 3 | 8 |
| 3 | 10 |
| 4 | 9 |
| 4 | 10 |
| 5 | 1 |
| 5 | 6 |
| 6 | 2 |
Search WWH ::




Custom Search