From the course: Database Foundations: Data Structures
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Solution: Build a relationship between tables
From the course: Database Foundations: Data Structures
Solution: Build a relationship between tables
(upbeat music) - [Instructor] For this challenge, we are looking at creating a movie database to help us keep track of the actors that have starred in various films. Now, we've already created a movie table and we have an actor's table. But what we need to do is relate those two tables together and we've figured out that we need a many-to-many relationship in order to make that work. So our task here is to create a junction table or a linking table that'll sit between those two other tables in the relationship chain. So we can get started here by saying CREATE TABLE. And the linking or the junction table is called MovieCast and it's going to have a couple of columns. The first one is going to be the PRIMARY KEY from the movies table, which is the MovieID, and that stores an integer value. We also need the PRIMARY KEY from the actor's table, which is ActorID, and that is also an integer value. And then we can add additional columns in this table that can be used to define the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
One-to-many relationships2m 13s
-
(Locked)
One-to-one relationships1m 27s
-
(Locked)
Many-to-many relationships2m 14s
-
(Locked)
Self-referencing relationships1m 56s
-
(Locked)
Cascade updates and deletes4m 35s
-
(Locked)
Challenge: Link tables with keys1m 8s
-
(Locked)
Solution: Link tables with keys6m 23s
-
(Locked)
Solution: Build a relationship between tables7m 54s
-
(Locked)
-
-
-