I am creating an application which will have a very large database to draw it's information from (a student registration system to be exact). The database is created with Microsoft SQL Server if that matters. I plan to implement the MVC pattern in this, but I am unsure of how to handle accessing the database.
My current understanding of how it should work is this (please correct me if there is a better way to do it):
- I have a model (for example User) that contains a few attributes and some business logic.
- When I need to view or edit the data in the table, I get the relevant data and put it in a model, change it and then 'save' the changes to the database. So for example if I need to change a student's name I will search the database for that student (by ID number) and instantiate a new User object. I would then change the Name property of the User object and run a 'save' method that uploads the data to the database.
I guess I have two questions: firstly am I understanding how the MVC pattern works with data driven applications and secondly where does the code for getting the data from the database to instantiate a model go? Does it go in the controller for said model? Does it go in some other static class? Is it a constructor for the model?