Should I build a view model in the code model layer or a view in the database?

Source: Internet
Author: User
Should I build a view model in the code model layer or a view in the database? Should I build a view model in the code model layer or a view in the database?

Reply content:

Should I build a view model in the code model layer or a view in the database?

Better in Model

Looking at the needs and teams, if there is a dba, it will make the process more comfortable in the database, because a layer of logic is abstracted in the middle, if well designed, it can improve reusability.

After comparison, you will know.
On the model layer, developers can intuitively understand the view and modify it as needed.
Creating a view in a database simplifies the business logic, but maintaining the view requires additional effort.

In fact, it's like a model has a hook like afterSave beforeSave, and a database also has a trigger. Which of the following is better? The former is transparent and well maintained, while the latter simplifies the logic and is more efficient.

In addition, you need to consider that the view data of the databases you are using, such as oracle and sqlserver, is cached, and query from the view is much faster than query using the table connection, however, the view data of mysql is non-cached and does not improve the performance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.