Summary
In this chapter, we covered some aspects of software testing and the way it is applicable to databases.
Unit testing techniques can be used when developing code in a database, for example, functions or triggers. Test-driven development is a very good approach in software development. Unit testing in databases has its own specificity. Unit tests for databases could be written as SQL scripts or stored functions in the database. There are several frameworks that help in implementing unit tests and processing the results of testing.
Another aspect of testing the database software is comparing data in the same database or between databases to test the results of refactoring the data model. This can be done via SQL queries, and sometimes, it requires establishing connections between databases. Connections between databases can be established via dblinks
or foreign data wrapper objects.
Database schemas can be compared quite simply using command-line tools provided with PostgreSQL and operating...