Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Understanding MVC!
You have completed Understanding MVC!
Preview
Learn what a "model" is and its role in the MVC framework.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
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 upYou need to sign up for Treehouse in order to set up Workspace
Sign up