When Behavior Driven Development BDD was introduced, some of the key principles were
- Requirements are behavior,
- Provides “ubiquitous language” for analysis,
- Acceptance criteria should be executable.
- Design constraints should be made into executable tests.
All of these principles can be applied to database development. When interacting with the database, we tend to assume certain behavior of the database. Some of this is universal, like when a row is inserted in a table, the same row can later be retrieved. There are other behaviors of the database on every project that are not that universal, like Person table should have at least firstname or lastname. This behavior changes based on the functionality being developed and thus needs to be properly specified and executed. The database lends itself very well to the new way of thinking in the BDD space, where the behavior of the objects is considered. BDD is similar to describing requirements in code.