Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ЭКЗ1-17.doc
Скачиваний:
2
Добавлен:
16.04.2019
Размер:
122.37 Кб
Скачать

14. Creating tables. Default data types. Field properties.

There are three ways to create a table in Access 2007.

You can create it:

  • From a template;

  • In Datasheet view;

  • In Design view.

As you enter data in each new field, Access chooses the appropriate data type for the field, such as Text, Number, or Date / Time.

As you enter new fields Access automatically names the fields Field1, Field2 and so on. To change this to a more meaningful name,

  • right-click the field header and select the Rename Column from the shortcut menu.

  • You can also use the Rename command in the Fields and Columns group of the Datasheet tab. Then enter the new name in the column header.

The easiest way to start a new table is to click the Table Design command in the Tables group on the Create tab. An empty table appears in the Design window, ready to add fields. The Design tab in the Table Tools ribbon appears.

The lower pane is devoted to specifying the individual field properties that correspond to the field selected in the upper pane, such as

      • size,

      • display appearance,

      • validity rules,

      • and so on.

The list of properties depends on the type of field you are entering.

15. Creating tables. Choosing a primary key. Relating tables.

There are three ways to create a table in Access 2007.

You can create it:

  • From a template;

  • In Datasheet view;

  • In Design view.

In a relational database system, to gather and retrieve related information from separate tables in the database, each record in one table must be unique in some way. The field or fields that contain the unique value is called the primary key.

Access never permits duplicate values in the primary key nor does it permit null values.

A valid unique value must be in the primary key field or field combination throughout the table. In Design view, you can tell which field contains the primary key by the key icon that appears in the left margin.

When you create a new table in Datasheet view, Access automatically adds the first field and assigns it as the primary key with AutoNumber data type.

The AutoNumber Access field type is an Access tool that can guarantee unique records in a table. Designating an AutoNumber field as the primary key for a table is probably the simplest way to set the key. Once the number is generated, it cannot be changed or deleted. Access will also ensure that no other record contains the same value in that field.

  • If your table has a field you are sure won’t contain any duplicate values, you can use that field as the primary key.

  • In the Table Design view, click the field row you want to use as the primary key, and then on the Design tab in the Tools group, click Primary Key.

  • To remove the primary key designation, repeat the step.

If you can’t guarantee that the values in a single field will be unique throughout the table, you can combine two or more fields as the primary key.

A primary key can be a combination of two or more fields whose combined value is unique for all records.

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