img
WHAT IS A DATABASE?
Developers sometimes struggle to describe what a database is. In one case, a database represents the
actual data, and in other cases, it may represent a piece of software that manages the data, an instance of
a process of this software, or even the physical machine that runs the manager process. Formally, a
database is a collection of data; the database software (such as Oracle, PostgreSQL, MySQL, and so on) is
called database management software or, more specifically, a relational database management system
(RDBMS); the instance of RDBMS is called a database engine; and finally, the machine that runs the
database engine is called the database server. However, most developers immediately understand the
meaning of the term database from the context in which it is used. This is why we use this term to
represent all four meanings just described.
In recent years, because of the explosive growth of the Internet and cloud computing technologies, a
lot of purpose-specific web applications such as social networks, search engine, maps, video, and so
on, have arisen. To serve those applications' specific data access requirements, a lot of different
categories of "databases" have also been developed. Some examples include key-value pair
databases (generally referred to as NoSQL databases), graphics databases, document-centric
databases, and so on. So, database is now a much broader term. However, a discussion of those
nonrelational databases is not within the scope of this topic, and we are referring to RDBMSs when we
mention databases throughout this topic.
Sample Data Model for Example Code
Before proceeding with the discussion, we would like to introduce a very simple data model that will
be used for the examples throughout this chapter, as well as the next few chapters when discussing
other data-accessing techniques (we will expand the model accordingly to fulfill the needs of each
topic as we go).
The model is a very simple contact database. There are two tables. The first one is the CONTACT table,
which stores a contact person's information, and the other table is CONTACT_TEL_DETAIL, which stores the
telephone details of a contact. Each contact can have zero or more telephone numbers; in other words,
it's a one-to-many relationship between CONTACT and CONTACT_TEL_DETAIL. A contact's information
includes their first name, last name, and date of birth, while a piece of telephone detail information
includes the telephone type (mobile, home, and so on) and the corresponding phone number. Figure 8-
1 shows the entity-relationship (ER) diagram of the database.
Figure 8-1. Simple data model for example code
As you can see, both tables have an ID column that will be automatically assigned by the database
during insert. For the CONTACT_TEL_DETAIL table, there is a foreign key relation to the CONTACT table, which
is linked by the column CONTACT_ID with the primary key of the CONTACT table (i.e., the ID column).
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home