Database Fundamentals
You have just been assigned a project: you must create and maintain a list of all the movies produced by your employer, Orange Whip Studios.What do you use to maintain this list? Your first thought might be to use a word processor. You could create the list, one movie per line, and manually enter each movie's name so the list is alphabetical and usable. Your word processor provides you with sophisticated document-editing capabilities, so adding, removing, or updating movies is no more complicated than editing any other document.Initially, you might think you have found the perfect solutionthat is, until someone asks you to sort the list by release date and then alphabetically for each date. Now you must re-create the entire list, again sorting the movies manually and inserting them in the correct sequence. You end up with two lists to maintain. You must add new movies to both lists and possibly remove movies from both lists as well. You also discover that correcting mistakes or even just making changes to your list has become more complicated because you must make every change twice. Still, the list is manageable. You have only the two word-processed documents to be concerned with, and you can even open them both at the same time and make edits simultaneously.The word processor isn't the perfect solution, but it's still a manageable solutionthat is, until someone else asks for the list sorted by director. As you fire up your word processor yet again, you review the entire list-management process in your mind. New movies must now be added to all three lists. Likewise, any deletions must be made to the three lists. If a movie tag line changes, you must change all three lists.And then, just as you think you have the entire process worked out, your face pales and you freeze. What if someone else wants the list sorted by rating? And then, what if yet another department needs the list sorted in some other way? You panic, break out in a sweat, and tell yourself, "There must be a better way!"This example is a bit extreme, but the truth is that a better way really does exist. You need to use a database.
Databases: A Definition
Let's start with a definition. A database is simply a structured collection of similar data. The important words here are structured and similar, and the movie list is a perfect example of both.Imagine the movie list as a two-dimensional grid or table, similar to that shown in Figure 5.1. Each horizontal row in the table contains information about a single movie. The rows are broken up by vertical columns. Each column contains a single part of the movie record. The MovieTitle column contains movie titles, and so on.
Figure 5.1. Databases display data in an imaginary two-dimensional grid.

Where Are Databases Used?
You probably use databases all the time, often without knowing it. If you use a software-based accounting program, you are using a database. All accounts payable, accounts receivable, vendor, and customer information is stored in databases. Scheduling programs use databases to store appointments and to-do lists. Even email programs use databases for directory lists and folders.These databases are designed to be hidden from you, the end user. You never add accounts receivable invoice records into a database yourself. Rather, you enter information into your accounting program, and it adds records to the database.
Clarification of Database-Related Terms
Now that you understand what a database is, I must clarify some important database terms for you. In the SQL world (you will learn about SQL in depth in Chapter 6, "Introduction to SQL"), this collection of data is called a table. The individual records in a table are called rows, and the fields that make up the rows are called columns. A collection of tables is called a database.Picture a filing cabinet. The cabinet houses drawers, each of which contains groups of data. The cabinet is a way to keep related but dissimilar information in one place. Each cabinet drawer contains a set of records. One drawer might contain employee records, and another drawer might contain sales records. The individual records within each drawer are different, but they all contain the same type of data, in fields.The filing cabinet shown in Figure 5.2 is the databasea collection of drawers or tables containing related but dissimilar information. Each drawer contains one or more records, or rows, made up of different fields, or columns.
Figure 5.2. Databases store information in tables, columns, and rows, the way records are filed in a filing cabinet.

Data Types
Each row in a database table is made up of one or more columns. Each column contains a single piece of data, part of the complete record stored in the row. When a table is created, each of its columns needs to be defined. Defining columns involves specifying the column's name, size, and data type. The data type specifies what data can be stored in a column.Data types specify the characteristics of a column and instruct the database as to what kind of data can be entered into it. Some data types allow the entry of free-form alphanumeric data. Others restrict data entry to specific data, such as numbers, dates, or true or false flags. A list of common data types is shown in Table 5.1.
DATA TYPE | RESTRICTIONS | TYPICAL USE |
---|---|---|
Character | Upper and lowercase text, numbers, symbols | Names, addresses, descriptions |
Numeric | Positive and negative numbers, decimal points | Quantities, numbers |
Date | Dates, times | Dates, times |
Money | Positive and negative numbers, decimal points | Prices, billing amounts, invoice line items |
Boolean | Yes and No or true and False | On/off flags, switches |
Binary | Non-text data | Pictures, sound, and video data |
Figure 5.3. Microsoft Access uses a drop-down list box to enable you to select data types easily.
[View full size image]

Figure 5.4. Unless you use the correct data type, data might not be sorted the way you want.

