Should data validation be done at the database level?

后端 未结 12 1503
半阙折子戏
半阙折子戏 2021-02-07 02:45

I am writing some stored procedures to create tables and add data. One of the fields is a column that indicates percentage. The value there should be 0-100. I started thinkin

12条回答
  •  逝去的感伤
    2021-02-07 03:26

    In general, I would think that the closer the validation is to the data, the better.

    This way, if you ever need to rewrite a top level application or you have a second application doing data access, you don't have two copies of the (potentially different) code operating on the same data.

提交回复
热议问题