Mysql VIEWS vs. PHP query

前端 未结 5 1005
温柔的废话
温柔的废话 2021-02-12 11:16

I am working on a web application which involves create list of Restaurants in various lists like \"Joe\'s must visit places\". Now for each Restaurant and list, I have display

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-12 12:18

    Disadvantages:

    • In my opinion databases are used for data layer and it is not that proper to put business code inside them. It both reduces maintainability and it contradicts clean separation of layers. The same applies to including business code and calculations in java scripts of web pages. For java script it is even more serious since it creates security threats. Source control for the code inside database is also another issue.

    • Now that code is inside database, the security and access complications (to views and stored procedures) is also added.

    • Migrating an application from one database engine to another will be much more difficult (since in addition to simple queries the stored procedures/views etc. are possibly different too). If the database is only about data then an abstraction layer could allow changing the database engine (at least on at some extent).

    Advantages:

    • Slight performance gains (since data is not coming out of the database for processing, it is processed right inside the database).

    • Code will seem cleaner (since the dirtiness is hidden inside the database views, stored procedures etc.).

提交回复
热议问题