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

16. Relating tables. Types of keys. Enforcing referential integrity. Cascade Update Related Fields option. Cascade Delete Related Records option.

  • The advantages of relating tables in a database are many. For example:

  • information retrieval routines operate much faster with matched fields, and errors are less likely to be introduced into the database during data entry.

  • Tables related at the table level in the Relationships window are ready for use in queries, forms, and reports.

  • When tables are related, you can add a subform or subreport that includes corresponding information from the related table.

  • Relating tables also helps maintain data integrity and cohesiveness.

The Relationships window provides all the tools you need to define and modify relationships and a table or query to the relationship, relate the tables and queries, specify the type of relationship, set up the referential integrity rules, and choose the join type.

To open the Relationships window, on the Database Tools tab’s Show /Hide group, click Relationships. If no relationships are defined in the current database, the Show Table dialog box appears in a blank Relationships window. The dialog box displays a list of all the tables and queries in the current database.

  • When you want Access to enforce the referential integrity rules on the relationship that you are defining, check Enforce Referential Integrity in Edit Relationships dialog box.

  • If, for some reasons, the tables already violate one of the rules, such as the related fields not being of the same data type, Access displays a message explaining the violation and does not apply the enforcement.

Single-Field Key

Multiple-Field (composite)

The Cascade Update Related Fields option lets you change the value in the primary key field in the parent table, and Access automatically changes the foreign key value in the child table to match.

This option preserves the relationship.

If the primary key in a table serves as a link to more than one table, you must set the Cascade Update Related Fields property for each of the relationships.

If not, Access displays a message that referential integrity rules would be violated by the cascading operation and refuses to delete or update the record.

The Cascade Delete Related Records option enables you to delete a parent record, and then Access automatically deletes all the related child records.

When you try to delete a record from the parent table of a relationship with this option selected, Access warns you that this record and the ones in the related tables will be deleted.

So, setting this property can be dangerous. If you delete records using a Delete query, access automatically deletes the related records without issuing a warning.

17. Sorting and filtering in Access. Difference between sorting and filtering. Sorting on text and numeric values. Sorting on Yes / No, Memo fields.

Sorting

When you enter data into your worksheet it is often unorganized making it difficult to examine. When analyzing the information in your spreadsheet, you may need to rearrange the data in different ways to answer different questions. Excel's sorting feature can help your rearrange your data so you can use it more efficiently.

Note: If your spreadsheet contains formulas, be careful when using the sort feature. Formulas rely on cell references to perform their calculations and moving the data with the sort feature may destroy these references. To sort a list of data:

  • Select a single cell in the column containing the data you want to sort.

  • Select the Home tab.

  • Under the Editing group, press the Sort and Filtering button and select the order you want your data to be sorted.

Note: If you select an entire column, Excel will sort only that column and will mismatch the data contained in the other columns.

Filtering is a way that you can use Excel to quickly extract certain data from your spreadsheet. Unlike sorting, filtering doesn't just reorder the list. It actually hides the rows or columns containing data that do not meet the filter criteria you define. Excel has an AutoFilter feature that makes it very easy to extract data from your spreadsheet. To use the AutoFilter:

  • Click on any cell in your spreadsheet.

  • Select the Home tab.

  • Under the Editing group, press the Sort and Filtering button and select the Filter button.

  • Drop-down menus will appear next to each cell heading.

  • Clicking on any drop-down menu will provide you with options for sorting or filtering

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