Datasheet

Chapter 1
12
Databases
When you start thinking about data sources, the most obvious one that springs to mind is the database,
which will generally provide the most reliable, scaleable, and secure option for data storage. When
you're dealing with large amounts of data, databases also offer the best performance. However, the very
fact that other solutions exist is a sure indication that in some circumstances, they're not the best choice.
In general, databases are designed to store large amounts of data in a manner that allows arbitrary
quantities of data to be retrieved in arbitrary order. For small collections of data, such as a set of contact
details, the time and other costs involved in creating and accessing a database might outweigh the
benefits that databases provide.
We'll have much more to say about the structure of databases in the next chapter, but as a quick
example, wanting to store some information about a company employee in a database might move us to
create a table called Employee that can contain the same pieces of data about a number of employees.
Such information could include their EmployeeID (number), LastName, FirstName, BirthDate,
and Country:
Employee
EmployeeID
LastName
FirstName
BirthDate
Country
Throughout this chapter, comparisons and demonstrations will be made of how data can be stored
and represented. For consistency, the same example is used throughout: that of storing details about
the employees in an organization.
One thing to note when we display a database diagram, compared to the diagrams of other data sources,
is that it's based on a model of the information being stored, rather than examples of the data. The way
in which databases actually hold information is largely hidden from the outside world, leaving us to
depict concepts rather than actual data items.
Text Files
At the opposite end of the scale from using databases to store information for a web site is the use of
text files. Although text files can store information in almost any conceivable format, they are generally
used for storing a set of data, one item on each line. If we were to capture the employee information
detailed above, we could store the LastName, FirstName, BirthDate, and Country of two
employees in a text file as follows:
Smith, John, 05-04-1979, UK
Bloggs, Joe, 29-09-1981, US