The purpose of using a relational database is that we want to avoid duplicating data in tables. How this is done is usually done by using a reference table. Reference tables (or sometimes called a bridge table) are a way to implement a many to many relationships between database schema entities (tables). A good rule of thumb is if you see data being duplicated across table rows, look to see if you need to implement a reference table.
I always like to use examples that make sense to me in real life. So for example, let's take an actor entity and a film entity. An actor can have many roles in different films and a film can have many actors filling different roles for that film. Creating a visual representation of your objects is always helpful. There are many tools out there, for this example I used DBDesigner.net in the browser for doing a quick mockup of our schema. Although most SQL tools also have designers available as well.
The use of a relationship table will eliminate the need to duplicate data which might otherwise be done to achieve the same many to many relationship. This is done by keeping both the actor's primary key and the film's primary key stored. At that point, if one were to do a query such as the following:
SELECT ACTOR.NAME, FILM.TITLE, FILM.GENRE FROM ACTOR JOIN FILM JOIN ACTOR_FILM_MAPPING ON ACTOR.ACTOR_ID = ACTOR_FILM_MAPPING.ACTOR_ID AND FILM.FILM_ID = ACTOR_FILM_MAPPING.FILM_ID;
This process of creating a relationship class or table between two entities is called normalization. By normalizing the data and linking the two tables with integer keys, the overall amount of data which must be scanned is less than if the data were flattened out by replication of rows in either table. Think of it as you would need many rows for the same actor if he were in many different films. Or that you'd many rows in your movie table for a single film that had many actors. Sometimes it might seem like a trade-off when spending extra time designing a database schema as such, but when the application scales and as databases grow it becomes apparent.
Hope you found this useful, I know I always gain something by writing about topics such as this.