Should data validation be done at the database level?

后端 未结 12 1493
半阙折子戏
半阙折子戏 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:37

    You can reasonable restrict the database so that the data always makes sense. A database will support multiple applications using the same data so some restrictions make sense.

    I think the only real cost in doing so would be time. I think such restrictions aren't a big deal unless you are doing something crazy. And, you can change the rules later if needed (although some changes are obviously harder than others)

提交回复
热议问题