Modelling Data1:25 with Jonathan Barrios
Learn what a "model" is and its role in the MVC framework.
The M in MVC stands for model and represents an application's knowledge, 0:00 in other words, what the application knows or its data. 0:06 Models represent data and interact with the database. 0:10 Creating, reading, updating, and deleting data, or CRUD for short. 0:13 For example, say a user visits a movie page on IMDb, 0:19 the URL is handed to the controller. 0:24 Remember, controllers handle all of the communication in the app. 0:27 The controller knows it needs some data so it talks to a particular model for 0:31 movie information. 0:36 The controller doesn't know how the model does what it does. 0:37 It just says, hey model, I need information about Toy Story. 0:41 And the model doesn't know anything about how that information will be used. 0:45 For example, what the final web pages will look like. 0:49 The model doesn't know anything beyond its single function. 0:52 An application will have different models for different pieces of data. 0:56 For example, a user model with data related to users on a site, 1:00 a movie model for a movie, an actor model for actor data, and so on. 1:05 After receiving the request the model returns the data to the controller. 1:10 In the IMDb example the model hands the Toy Story data to the controller. 1:15 And the controller, as you'll see next, hands the data to the view. 1:20
You need to sign up for Treehouse in order to download course files.Sign up