A Brief Review of Database Basics
Database services under Linux that use the software discussed in this chapter
are based on a client/server model. Database clients are often used to input
data and to query or display query results from the server. You can use the
command line or a graphical client to access a running server. Databases
generally come in two forms: flat file and relational. A flat file database can
be as simple as a text file with a space, tab, or some other character delimiting
different parts of the information. One example of a simple flat file database
is the /etc/passwd file. Another example is a simple address book that
might look something like this:
Click here to view code image
Doe~John~505 Some Street~Anytown~NY~12345~555-555-1212
You can use standard UNIX tools such as grep, awk, and perl to search
for and extract information from this primitive database. Although this might
work well for a small database such as an address book that only one person
uses, flat file databases of this type have several limitations:
They do not scale well—Flat file databases cannot perform random
access on data. They can only perform sequential access. This means
they have to scan each line in the file, one by one, to look for specific
information. As the size of the database grows, access times increase,
and performance decreases.
Flat file databases are unsuitable for multiuser environments
—Depending on how the database is set up, it either enables only one
user to access it at a time or allows two users to make changes
simultaneously, and the changes could end up overwriting each other,
which results in data loss.
These limitations obviously make the flat file database unsuitable for any kind
of serious work in even a small business—much less in an enterprise
environment. Relational databases, or relational database management
systems (RDBMSs) to give them their full name, are good at finding the
relationships between individual pieces of data. An RDBMS stores data in
tables with fields much like those in spreadsheets, making the data searchable
and sortable. RDBMSs are the focus of this chapter.
NOSQL
There is an exception to what we just said. A fairly new category of
databases is now in use, usually referred to as NoSQL in casual
conversation. Unlike typical flat file databases, NoSQL databases are a