Is creating a “dummy record” to make the database obey business logic, a good idea or a dumb one?

In some projects, I see that a fictitious record is required to create in Db in order to continue the business logic without violating the limitations of Db.

So far I have seen its use in two ways:

  • By adding a field of type IsDummy
  • Adding a field called ObjectType indicates the type: Dummy

Well, it helps in achieving something.

But what makes me wary of such decisions is sometimes necessary to keep in mind that the application has some kind of dummy records that need to be processed in some processes. If not, you encounter some problems until you realize your existence, or until someone from the team says to you: "Yeah! You forgot the dummy entries. You should also ..."

So the question is: Is it a good idea to create dummy entries to maintain business logic without making Db complaints? If so, what are the best practices that allow developers to abandon their existence? If not, what do you do to not get into a situation where you have the only option for creating a dummy record?

Thank!

+3
8

, .

, (, , ), , .

+6

, , , / . , . .

, " ".

- [, ] ANSI SQL Constraints, Checks Rules. (, Domains/Datatypes .., "-".) , , .

, . , , , , ; , .

( ). ( ), , .

+5

. , - , ...

+4

"" .

, . , , . , . , .

+4

, "dummy", - .

, , .

- , : , CORRECT ; , , .

+3

, , - , "-" .

, " : Dummy", , - ORM . ( ) ORM-, NHibernate, , , . , , (, , , ).

- "", , . , , . FIRST, . - . , " "?

. . .

+2

.

, , , .

, .

, , , , , , , , .

+2

-.

:

, Package, -, - . - Db . , , . , , , .

, , - . . , , VALID- , -, .

"dummy" - . , "" -, .

If a package without content is invalid, then dummy data that allows "compliance" with the business level is a stupid hack. In essence, you wrote the rules to protect your own system, and then how you try to circumvent your own protection. On the other hand, if a package without content is valid, then the business layer should not apply dummy restrictions. In no example are dummy data valid.

+2
source

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


All Articles