15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

612<br />

The Basics of Databases<br />

Database File<br />

Bo Katz<br />

948 Main Street<br />

Baltimore, MD<br />

01478<br />

Bogg Smith<br />

153 Main Street<br />

Detroit, MI 48154<br />

Fields<br />

Sally Riggins<br />

3 Darth Street<br />

Billings, MO<br />

78140<br />

Jim Bagley<br />

459 Terrance<br />

Houston, TX<br />

84501<br />

Records<br />

Figure 1-2:<br />

A flat-file<br />

database<br />

stores data<br />

in fields and<br />

records.<br />

Ann Johnson<br />

43 Parkway<br />

Boston, MA 01245<br />

Ian Slater<br />

934 Black Drive<br />

San Francisco, CA<br />

94781<br />

Flat-file databases impose a structure on the type of in<strong>for</strong>mation you can store<br />

to make retrieving in<strong>for</strong>mation much easier later. However, you need to design<br />

the structure of your database carefully. If you define the database to store<br />

only first and last names, you can’t store any other in<strong>for</strong>mation other than first<br />

and last names.<br />

Designing the size and types of fields can be crucial in using the database<br />

later. If you create a Name field but allocate only ten characters to hold that<br />

data, the name Bob Jones fits but another name, such as Daniel Jonathan<br />

Perkins, cuts off.<br />

Another problem is how you define your fields. You could store names in<br />

one big field or separate them into three separate fields <strong>for</strong> holding first,<br />

middle, and last names. Using a single field to store a name might initially<br />

look simpler, but separating names in different fields is actually more useful<br />

because this allows the database to sort by first, middle, or last name.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!