In the chapters that follow we will cover different aspects of database consistency and ways to maintain it. Speaking about consistency, it is important to distinguish between two different aspects of it: structural and logical consistency.
Structural consistency means that all internal structures of the database are in good order, contain valid data and are coherent with one another. Structural consistency means that the database is in good shape technically, but it does not imply that the data it contains are in any way meaningful.
Logical consistency means that the data stored in the database are coherent with respect to the application logic. Usually this implies that structural consistency is observed as well.
For as long as the program is free from memory management errors and each opened database is properly closed before the program terminates, structural consistency is maintained. Maintaining logical consistency is more complex task and its maintenance is entirely the responsibility of the application programmer. See Crash Tolerance, for a detailed discussion.
Both consistency aspects can suffer as a result of both application errors that cause the program to terminate prematurely without properly saving the database, and hardware errors, such as disk failures or power outages. When such situations occur, it becomes necessary to recover the database.
In the next chapter we will discuss how to recover structural consistency of a database.