Storing SQL queries in a table on sql server

We have several tasks in our system. These tasks are listed in the grid. We have 3 different custom types ( usertypeid1,2,3). For each user, the list is different, and he can filter the list by selecting a view from the drop-down list. ViewNamethe table below shows the view you want to display. To achieve this functionality, one developer created the following table structure and saved sql fragments SQLExpressionin the table below. In my opinion, the request should not be stored in the database. What are the pros and cons of this approach and what are the available alternatives?

JobListingViewID         ViewName        SQLExpression            UserTypeID
 3                     All Jobs            1 = 1                       3
 4                     Error Jobs   JobStatusID IN ( 2 )               1
 5                     Error Jobs   JobStatusID IN ( 2 )               2
 6                     Error Jobs   JobStatusID IN ( 2 )               3
 7                     Speech       JobStatusID IN ( 1, 3, 8 )         1
+3
source share
3

Matrix ViewName UserTypeID JobStatusID , . SQL DB.

. " " , JOIN. , , . , .

ViewName        JobStatusID        UserTypeID
Error Jobs             2                1
Error Jobs             2                2
Error Jobs             2                3
Speech                 1                1
Speech                 3                1
Speech                 8                1
+1

: 1. . 2. ( ..). 3. , . , , .

+1

I think the developer is right, and this approach, if it works for him (and for the rest of the system), is just as good as any other. Try again later if this causes a problem - performance, maintenance, something ...

0
source

Source: https://habr.com/ru/post/1747129/


All Articles