Share via


Working with a Database

A database provides a working environment where you can store a collection of tables, establish relationships between the tables, and set properties and data validation rules that control how the related tables work together. A database is stored as a file with a .dbc extension.

Contents of a database

You can use databases independently or incorporate them into a project by adding them to the Project Manager. To access the tables within a database, the database must be open.

To open a database

  1. In the Project Manager, select the name of the database you want to use.
  2. Choose Modify.

You can also choose Open from the File menu and choose the name of a database.

To look at the structure of a sample database, try opening Testdata.dbc, which is found in the Visual FoxPro \Samples\Data directory.

When you open a database, the Database Designer appears, showing you the tables that make up the database, and the relationships between them.

Tables in the Database Designer

The Database Designer toolbar displays so that you can quickly access database-related options. Database commands are available on the Database menu; you can also display shortcut menus by clicking the right mouse button in the Database Designer.

You can resize the tables in the Database Designer to see more or less of the fields and the indexes they contain, or collapse the table to show only the table names, which is helpful if your database contains many tables.

To expand or collapse a single table

  1. Place the pointer on a table in the Database Designer and click the right mouse button
  2. Choose Expand or Collapse.

To expand or collapse all the tables

  1. Place the pointer in the Database Designer and click the right mouse button

  2. Choose Expand All or Collapse All.

    Collapsed view of tables in a database

You can change the layout of your tables displayed in the Database Designer. For example, after working in the database, you might want to return the tables to the default height and width or you might want to improve the layout by aligning the tables.

To arrange the tables in a database

  • From the Database menu, choose Arrange, and then select the appropriate options in the Find Table or View dialog box.

    In the Database Designer, the title bar of the table you selected is highlighted.

    To Select
    Arrange the tables alphabetically by name By name
    Arrange the tables by type By type
    Align the tables in a row Horizontally
    Align the tables in a column Vertically
    Return the tables to their original size Resize objects to default height and width

See Also

Creating Databases | Adding Tables to a Database | Browse | Removing a Table from a Database | Updating Table and Database Links | Creating a Database | Database Designer | Project Manager