1 00:00:00,000 --> 00:00:05,408 [MUSIC] 2 00:00:05,408 --> 00:00:10,016 All right, let's explore how to create data relationships using Sequelize by 3 00:00:10,016 --> 00:00:12,364 updating a simple Node.js application. 4 00:00:12,364 --> 00:00:16,511 To get started and follow along, download the project files with this video, and 5 00:00:16,511 --> 00:00:20,255 open them in your preferred text editor, I'm using Visual Studio Code. 6 00:00:20,255 --> 00:00:25,222 As you follow this course, you'll make changes to the app.js file, 7 00:00:25,222 --> 00:00:29,949 and the movie.js, and person.js files in the db/models folder. 8 00:00:29,949 --> 00:00:33,300 Be sure to review the teachers notes with this video to learn more about what's 9 00:00:33,300 --> 00:00:34,690 included in the project files. 10 00:00:34,690 --> 00:00:39,388 The project contains two models, person and movie. 11 00:00:39,388 --> 00:00:42,890 To start with, neither model has any relationships defined, 12 00:00:42,890 --> 00:00:44,351 we'll do that part soon. 13 00:00:44,351 --> 00:00:49,458 To run the application, install the necessary dependencies in your terminal or 14 00:00:49,458 --> 00:00:53,182 console by running the command `npm install`. 15 00:00:53,182 --> 00:00:56,933 After the dependencies finish downloading and installing, 16 00:00:56,933 --> 00:00:59,298 run `npm start` to start the application. 17 00:00:59,298 --> 00:01:02,132 You'll notice that as you build the project, 18 00:01:02,132 --> 00:01:05,193 several actions will occur in a specified order. 19 00:01:05,193 --> 00:01:11,156 I added these actions as console.log statements in db/index.js and app.js. 20 00:01:11,156 --> 00:01:16,013 For example, instantiating and configuring the Sequelize object instance, 21 00:01:16,013 --> 00:01:20,880 importing the database models, configuring their associations, and so on. 22 00:01:20,880 --> 00:01:24,379 This way, you'll know the step at which each action occurs. 23 00:01:24,379 --> 00:01:28,961 You'll write the functionality that performs these actions as you follow along 24 00:01:28,961 --> 00:01:29,920 in this course. 25 00:01:31,581 --> 00:01:36,062 For instance, by the end, you'll produce the following console output, 26 00:01:36,062 --> 00:01:40,717 displaying data returned from the database, and 27 00:01:40,717 --> 00:01:44,466 create database tables that looks similar to this. 28 00:01:46,523 --> 00:01:51,117 All right, now you're ready to define data relationships for the person and 29 00:01:51,117 --> 00:01:52,045 movie models. 30 00:01:52,045 --> 00:01:57,055 Then update the database with records that make use of the data relationships, 31 00:01:57,055 --> 00:02:00,661 and finally, retrieve related data from the database.