Is it good to check that some fields are blank or not from a table and 开发者_StackOverflow社区return true or false from a sp Or is it good to fetch the values and check in the code.
It is generally better design to have a specific business layer, which validates fields. In an n-Tier architecture for example, the Business Layer would validate and return an error if required fields are missing. This means the data layer expects valid data coming from the business layer.
All the data layer has to worry about is manipulating/retrieving data effectively and efficiently.
In addition, adding constraints to the table will protect you in the event your BLL lets invalid data through. Although it adds to the complexity in maintaining and extending the application, the pain endured when rubbish does get into your production DB is far greater.
It's a bit of a judgement call based on your available skills sets and development practices for your company/product/project.
精彩评论