SQL Best Practices for Hard Coding Identity Values

First, I know this is a rather subjective question, but I need formal documentation to help me train my client.

Background is a large enterprise application with hundreds of tables and SPs, all of which are clearly designed with normalized tables and foreign keys using identifier columns.

Our client has several employees who write sophisticated reports at Crystal using a replicated copy of our Db products.

We have tables that store what I will classify as basic information about the system, such as a list of offices or departments within the company, a standard set of roles for users, statuses of other objects (open / closed, etc.), mostly data that doesn't change often.

Problem - Report developers and financial analysts write queries with hard-coded identity values ​​within them. Something like that

SELECT xxx FROM OFFICE WHERE OFFICE_ID = 6

I am greatly simplifying here, but they mostly use these hard-coded int values ​​inside their routines everywhere.

For SQL developers who see this, facepalm will obviously make you, since it's just a built-in instinct to not do this.

However, surprisingly, I can not find any documentation or even articles from best practices on why this should not be done.

, , , , (/QA/Dev) , .

SQL - / .., , , ?

+4
1

, - "... [ ]". .

, . . , ...

  • ,

... , , , ( , , ). , , - , "//" (, ( ) [CategoryName], CatgoryName - , , . [CategoryId] - , , )

- , , , , / , ,

, , . , , "" "" . , , , , , . , .

, , , , . business/natural/alternate, , .

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

+3

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


All Articles