Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SSW_8_11.doc
Скачиваний:
2
Добавлен:
01.05.2025
Размер:
5 Мб
Скачать
☆

12. The elements of Database Programming

12.1 Understanding Database Concepts

The databases are one of the most popular computer applications. Virtually every business uses databases to keep track of everything from its customer list to the company payroll. Unfortunately, there are many different types of database applications, each of which defines it’s own file layouts and rules.

Now Visual C++ includes classes that are built upon the ODBC (Open Database Connectivity) and DAO (Data Access Objects) systems. Using AppWizard, you can create a simple database program without writing even a single line of C++ code. More complex tasks do require some programming but not as much as someone might think.

Defined simply, a database is a collection of records. Each record in the database is comprised of fields. And each field contains information that's related to that specific record. For example, suppose you have an address database. In this database, you have one record for each person. Each record contains six fields: the person's name, street address, city, state, ZIP Code, and phone number. So a single record in your database might look like this:

NAME: John Smith

STREET: 25 Holland Dr.

CITY: Hartford

STATE: UK

ZIP: 60084

PHONE: 044-555-3542

The entire database will contain many records like the one just shown, each record containing information about a different person. To find a person's address or phone number, you search for his or her name. When you find that name, you also find all of the information that's included in the record with the name. This type of database system uses the flat database model. For home use or for small businesses, the simple flat database model can be a powerful tool. However, for large databases that must track dozens, or even hundreds, of fields of data, the relational database model is more appropriate.

A relational database is like several flat databases linked together. Using a relational database, you can, not only search for individual records as you can with a flat database, but you can also relate one set of records to another. This enables to store data much more efficiently. Each set of records in a relational database is called a table. The database management system (DBMS) can link these tables together in various ways by comparing keys that were defined by the person who created the database.

The example relational database that you'll use in this chapter was created using Microsoft Access. The database is a simple system for tracking employees, managers, and the departments for which they work. Figures 22.1, 22.2, and 22.3 show the tables that I defined when I created the database. The Employees table contains information about each of the store's employees; the Managers table contains information about each store department's manager; and the Departments table contains information about the departments themselves. (This database is very simple and probably not usable in the real world.)

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]