CIS 155 Table Relationship
Examining Access Objects The seven Access objects. Database Queries Based on tables Forms Reports Pages Forms, Reports, and Pages are based on tables or queries Macros Modules
Examining Access Objects (cont.)
Examining Relationships An Access database is a relational database because more than one table can share information or “relate.” Minimizes redundant information The process of designing a relational database is called normalization, which involves determining appropriate fields, tables, and table relationships
Examining Relationships (cont.) Enforce Referential Integrity. Means that you cannot enter values in the foreign key field unless you first enter them in the primary key field Also means that you cannot delete records in the “one” table if the “many” table has corresponding related records Cascade Update Related Fields. Automatically updates the data in the foreign key field when the matching primary key field is changed
Examining Relationships (cont.) Cascade Delete Related Fields. Automatically deletes all records in the “many” table if the record with the matching field in the “one” table is deleted
Examining Relationships (cont.) Foreign key field Data number type
Examining Relationships (cont.) “many” table “one” table Linking field Relationship type
Examining Relationships (cont.) One-to-many link with referential integrity “One” symbol Primary key field in the “one” table Foreign key field in the “many” table “Many” symbol
Examining Relationships (cont.) Relationship types
Relational Databases (cont.) Tables in the same database should be related, or linked, through a common field in a one-to-many relationship The primary key field in one of the tables creates the “one” side of the relationship and the foreign key field in the other table creates the “many” side of the relationship The foreign key field contains the same value “many” times to create a one-to-many relationship between the tables
Examining Relational Databases (cont.) A single table with duplicate information
Relational Databases (cont.) One-to-many relationships
Relational Databases (cont.) Many-to-many relationships. To join two tables that have a many-to-many relationship, you must establish a third table, called a junction table A junction table creates separate one-to-many relationships with the two original tables
Planning Related Tables and Lookups A well designed database minimizes redundant data. Related tables planning guidelines. List all of the fields of data that need to be tracked Group fields together in subject matter tables Identify primary key fields that exist in tables Link the tables with a one-to-many relationship via a common field
Planning Related Tables and Lookups (cont.) Related tables planning guidelines (cont.) Create lookups Lookups are reference tables or lists that are used to populate the values of a field Lookups are established by adding properties to the field for which you want to lookup behavior to occur Fields that contain lookup properties are called lookup fields
Planning Related Tables and Lookups (cont.) One-to-many relationship Linking SSN field Linking CourseID field
Planning Related Tables and Lookups (cont.) Lookup fields
Planning Related Tables and Lookups (cont.) Identifying key field combinations. Identifying a single primary key field may be difficult in some tables When individual fields can’t serve as a valid key field, combine fields together to make a key field combination
Creating Related Tables All characteristics of a table are defined in the Table Design View. Field names, data types. Field descriptions, primary key field A key symbol indicates that a field is defined as the primary key field
Creating Related Tables (cont.) Primary Key button
Creating Related Tables (cont.) Comparing linked to imported tables. The data in a linked table is stored in a file that is separate from the open database An Excel workbook can be linked to Access An imported table is a copy of data from an external file. Works the same as a table created in Access
Creating One-to-Many Relationships Once the initial database design and table design is completed, you need to link the tables together. Use a one-to-many relationship Create queries, reports, and forms with fields from multiple tables
Creating One-to-Many Relationships (cont.) “Many” side of the one-to-many relationship Bold identifies a primary key field “One” side of the one-to-many relationship
Creating One-to-Many Relationships (cont.) Enforcing referential integrity. Referential integrity is a set of rules that help ensure that no orphan are entered or created in the database An orphan record is a record in the “many” table that doesn’t have a matching entry in the linking field of the “one” table Prevents a user from deleting a record from the “one” table if a matching entry exists in the linking field of the “many” table