Lesson 1-3
Lesson 1-3
Communications Technology
LESSON 1:
INTRODUCTION TO VISUAL FOXPRO
Information and Communications
Technology
When you create a database, you gather l Captions on fields that display in Browse windows and
Grid columns as headers.
tables together into one collection and gain
the benefit of data dictionary features. l Default values on fields.
A data dictionary gives you greater l The default control class used in forms.
flexibility in designing and modifying the l Input masks and display formats for fields.
database, and frees you from having to
write code to create field-level and row- l Field-level rules and record-level rules.
level validation or to ensure the uniqueness l Triggers.
of values within primary key fields. The l Stored procedures.
Visual
l Connections to remote data sources.
FoxPro data dictionary enables you to
create or specify: l Local and remote views.
l Comments for each field, table, and database.
Collecting Tables into a Database
To collect tables into a database, you need to create a database container to hold all of the objects such as views,
connections, and stored procedures associated with the tables that make up your database.
To create a new database
In the Project Manager, select the Data tab, then select Databases from the list and choose New.
-or-
l Use the CREATE DATABASE command.
For example, the following code creates and exclusively opens a new database called Sample:
CREATE DATABASE Sample
When you create a new database, it is empty,
containing no associated tables or other
objects. Adding a table creates links between
the table file and the database container. The
link information stored in the database about a
table is a forward link.
The link information stored in the table about
the database container is the backlink.
Adding Tables to a Database
Each Visual FoxPro table can exist in one of two states:
1. either as a free table, which is a .dbf file that is not associated with any
database, or
2. as a database table, which is a .dbf file that is associated with a database.
Tables associated with a database can have properties that tables outside a
database do not have, such as field-level and record-level rules, triggers, and
persistent relationships.
You associate tables with a database by creating them within an open database,
or by adding existing tables to a database.
To add a free table to a database
In the Project Manager, select Tables from the All tab or the Data tab, then choose Add.
-or-
l Use the ADD TABLE command.
For example, the following code opens the testdata database and adds the orditems table:
OPEN DATABASE testdata
ADD TABLE orditems
You must explicitly add an existing free table to a database to make it a part of a database. Modifying the structure
of a free
table does not cause Visual FoxPro to add the free table to a database, even if a database is open when you issue
the MODIFY
STRUCTURE command.