Chapter 6: Database

The central aspect of an application is usually the data themselves. For example, a book-selling website's most valuable asset is its data on books and users. Previously, we store these data in either code or files, and they would be loaded into memory at runtime. It is clear that pure in-memory based storage has many pitfalls. For example,

  • Data would be lost when the system shuts down.
  • It is very difficult to support multiple users at the same time.
  • Memory cannot hold large size of data.

File-based processing system can alleviate partial problems, but it further poses new challenges for programming, such as difficulty in accessing data, data redundancy and inconsistency. Those difficulties, among others, prompted the development of database systems. A primary goal of a database management system (DBMS) is to provide a way to store and retrieve database information that is both convenient and efficient.

[!NOTE] Database is one of the core courses in Computer Science, and we can only cover a very small part of it in this book. Readers can refer to other textbooks, such as Database System Concepts, if they wish to learn more about databases.

In this chapter, we will learn the basic concepts about (relational) database, and especially, how to use database in Java web.