Download presentation
Presentation is loading. Please wait.
1
1 Chapter 2 Reviewing Tables and Queries
2
2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics of a well- designed table Create a new Access table with its corresponding fields, keys, indexes, validation rules, input masks, and formats
3
2 Chapter Objective Create relationships between tables Create select queries, totals queries, and action queries Create queries in SQL view
4
2 The Access Application Development Process Structured systems development approach Includes a formal requirements specification phase, followed by the creation of an application blueprint, and then by programming Prototyping approach Requires the developer to build an initial system quickly, with a shorter requirements and design phase
5
2 The Access Application Development Process Figure 2-1 Access application development process
6
2 Table Development Data constraints Valid values for the data Many can be enforced through the design of the Access tables and relationships
7
2 Terminology and Rules of Table Design Figure 2-2 Design view of tblCurrentSt udents
8
2 Terminology and Rules of Table Design Primary key A field or a combination of fields that always contains a value that uniquely identifies a row in a table Composite key (or multiple-field primary key) A primary key that consists of two or more fields Foreign key A field or a combination of fields that contains values that are also contained by a primary key (usually, but not always, located in another table) May also be null
9
2 Terminology and Rules of Table Design Figure 2-3 Query that retrieves students who need MKTG 641 (good table design)
10
2 Terminology and Rules of Table Design Figure 2-4 Query that retrieves students who need MKTG 641 (poor table design)
11
2 Terminology and Rules of Table Design Points to follow when constructing tables: When two or more tables contain the same fields, consider collapsing the multiple tables into a single table When a table contains several similar fields, consider creating another table that contains the primary key of the original table plus a single field that combines the similar fields of the original table
12
2 Terminology and Rules of Table Design Points to follow when constructing tables (continued): If the values of two or more fields always appear together in different rows, whether in the same or different tables, consider creating a new table that contains the related fields Creation process is called normalization
13
2 Normalization Process that involves splitting tables into more than one table in an effort to control data redundancy Dependency Exists between fields when a filed or fields determine the value of another field
14
2 Normalization Table 2-1 Normal form summary
15
2 Normalization Table 2-1 Normal form summary (continued)
16
2 Constraints in the Design View of a Table Field Name column Contains the name of the field Data Type column Identifies the kind of data that can be stored in the field Enforces a constraint Field Size property Specifies how many characters or the type of number that can be contained in the field Provides an additional constraint that validates the entry of data into a field
17
2 Constraints in the Design View of a Table Additional data types supported by Access: AutoNumber Tells Access to generate a value for the field automatically ReplicationID Used when copies of a table are kept on more than one computer Ensures that the value generated for the field is unique across different computers
18
2 Constraints in the Design View of a Table Table 2-2 Data types supported by Access
19
2 Constraints in the Design View of a Table Table 2-2 Data types supported by Access (continued)
20
2 Field Properties for Constraint Enforcement and Formatting You can specify the non-null constraint for non- key fields by choosing Yes in the Required field property Non-null constraint Requires that all records contain a value for that field Zero-length string A valid value that is defined as “” Choosing No in the Allow Zero Length field property prevents the use of zero-length strings
21
2 Field Properties for Constraint Enforcement and Formatting Index Maintains a sorted list of the current values of a field or fields Items in the list point to the records that have the identified value Created automatically for primary keys
22
2 Field Properties for Constraint Enforcement and Formatting Figure 2-6 Indexes window of tblLevelingNeeded
23
2 Validation Rules and Validation Text Field Properties Validation rule Condition that the corresponding field must satisfy Validation text Displayed if the condition of validation rule is not satisfied Conditional expression Any statement that can be evaluated as True or False
24
2 Table Properties Validation Rule Table Properties validation rule Required when a constraint requires a comparison of the contents of two or more fields in the same table Typed in the Table Properties sheet
25
2 Table Properties Validation Rule Access allows the creation of fairly complex validation rules Between, In and Like Operators that return True or False values Dlookup function Used in a table-level validation rule to compare a value to values found in another table
26
2 Table Properties Validation Rule Input mask Constraint mechanism Guides users as they type input Prevents users from typing incorrect values Input Mask Wizard Helps set up input masks Default Value field property Specifies the initial value of the corresponding field
27
2 Table Properties Validation Rule Table 2-4 Input Mask symbols
28
2 Properties Used for Formatting Caption property Refers to the heading or prompt that will initially appear on a form or report when the corresponding field is included The default type of control that appears on a form or report is specified through the Display Control combo box, which is located in the Lookup tab in the Field Properties section of the table’s Design view
29
2 Properties Used for Formatting Description column Affects a form by placing the value of the Description column as the default status bar text Format field property Used to indicate how stored data should be displayed
30
2 Properties Used for Formatting Table 2-5 Symbols used in the Format property
31
2 Multiple Table Relationships Foreign keys Used to maintain relationships between tables Joining the tables Process of matching common attribute values
32
2 Multiple Table Relationships Referential integrity A constraint on data values that forces the value of a foreign key to either: Match a primary key value that is contained in a row of the related table or Equal null Explicit relationships also facilitate the use of subdatasheets Allow you to display related records that are nested within the datasheet of a table
33
2 Multiple Table Relationships Figure 2-7 Some of the relationships in the Relationships window for MU-DSci
34
2 Multiple Table Relationships Referential integrity between the primary key and foreign key is enforced by placing a check mark in the Enforce Referential Integrity check box In the Relationships dialog box, when Cascade Update Related Fields is checked, changes in the primary key value are automatically propagated to the corresponding foreign key value
35
2 Multiple Table Relationships Figure 2-8 Relationships dialog box between the tblCurrentStudents and tblLevelingNeeded
36
2 Multiple Table Relationships When Cascade Delete Related Records is checked, row deletions in the primary key table will cause deletions of related rows in the foreign key table One-to-one relationship Indicates that a value of the primary key can exist in only one row as a foreign key One-to-many relationship Indicates that a value of the primary key can exist in more than one row as a foreign key
37
2 Linked Tables To use linked tables, you must: Develop table definitions and table data in one database called the source database Develop the queries, forms, reports, pages, macros, and modules in a different database called the container database
38
2 Query Development Queries Provide an efficient and easy method of retrieving, manipulating, and summarizing data Access queries are specified in the Structured Query Language (SQL) Action queries Make-table, update, append, and delete queries
39
2 Query Development Join lines Relationships predrawn between selected tables in the query’s Design view if relationships have been declared between tables or if Access can guess relationships between tables Created by dragging a field from one table to a field in another table
40
2 Query Development Figure 2-11 Access Query menu and design grid
41
2 Query Development Figure 2-12 Query showing the leveling courses needed by each current student
42
2 Select and Crosstab Queries Select queries Retrieve data from other tables or queries Field names appear in the Field row of the grid Criteria row of grid Limits the displayed rows to those that meet a specified condition Contains any statement that evaluates to True or False
43
2 Joins Inner join Default join type Includes rows only when the fields being compared contain matching values
44
2 Joins Figure 2-13 Join Properties dialog box
45
2 Totals Queries Totals queries Select queries that aggregate values The Group By item in the Total list box Tells Access to aggregate the other fields per each unique value within the Group By field
46
2 Totals Queries A Where specification in the Total row States that the field will be tested for a criterion before it is included in the aggregations specified by the other columns Crosstab query Similar to a totals query, except that the former requires at least two Group By fields
47
2 Action Queries Delete queries Remove rows from a table Figure 2-16 Design view of qryDeleteDen iedProspects
48
2 Action Queries Make-table queries Similar to select queries, except that the query results are physically stored in a new table Append queries Similar to make-table queries, except that the results of the select query are appended to an existing Access table Update queries Change field values in existing rows in a table
49
2 Parameter Queries Parameter queries use parameters to substitute for the constant values placed in the query grid Figure 2-17 Design view of the qryUpdat ePrice update query
50
2 Chapter Summary Queries, forms, reports, macros, pages, and modules display or manipulate the data contained in the tables Applications should attempt to ensure data integrity through table and relationship design Primary keys, input masks, validation rule, and referential integrity can all be used to enforce data constraints
51
2 Chapter Summary Queries are closely related to tables Totals and crosstab queries aggregate data stored in the tables Action queries update data in the tables Like tables, queries are commonly used by forms, reports, pages, macros, and modules
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.