Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to MS Access: creating tables, keys, and relationships

Similar presentations


Presentation on theme: "Introduction to MS Access: creating tables, keys, and relationships"— Presentation transcript:

1 Introduction to MS Access: creating tables, keys, and relationships
BSAD 141 Dave Novak

2 Topics Covered Brief introduction to MS Access Normalization
Name and save a DB file Create tables and keys Create and enforce relationships Convert a partial ERD to design in Access Examples of both entity integrity and referential integrity using Access Normalization Example

3 Important to note! If you are having trouble keeping up with the lecture or having some type of technical problems, you may need to read through the book and notes and work through the examples These will walk you through the basic features in MS Access and guide you through table and key creation as well as how to create relationships between tables

4 Example: Partial ERD Consider a relationship between a manager and a project Assume the following: Each manager can manage up to 5 different projects simultaneously Each manager must manage at least one project Each project is assigned to only 1 manager (there are no co-manager leads on the project) When entered into the DBMS, each project must be assigned to a manager

5 Example: Partial ERD Draw the partial ERD – discuss degree, connectivity, and existence

6 Two Types of RDBMS Integrity Rules
1) Entity Integrity Guarantees each entity (where each row in a table represents a unique entity) has a valid and unique PK (no missing or repeat values) 2) Referential Integrity All FK values (on the many side of the relationship) must first exist in the parent table (values must be first be entered conform to entity integrity on the one side of the relationship)

7 Two Types of RDBMS Integrity Rules
In practice this means that once you have established the correct relationships between the tables in relational DB, enter the data for all tables on the ONE side of the relationship before entering any data for any table on the MANY side of the relationship

8 Building Tables in Access
Create a DB file called “class-example1” Build 2 separate tables that correspond to the partial ERD you just drew Attributes for Manager (ManagerID, FirstName, LastName, Address, Salary) Attributes for Project (ProjectID, ProjectName, Duration, Phase) Model the relationship in Access and enforce referential integrity

9 Building Tables in Access
1) Create the “shell” or empty tables to begin with 2) Specify the data type for each attribute Manager (ManagerID (txt), FirstName (txt), LastName (txt), Address (txt), Salary (currency)) Project (ProjectID (txt), ProjectName (txt), Duration (txt), Phase(txt))

10 Link the tables using a Foreign Key
Using our ERD and what you know about the location of Foreign Keys FK: Which table does the FK appear in? What is the FK attribute? Go into design view and add the FK attribute

11 Enter Data in Manager Table: Entity Integrity Error
You get an error message if you violate entity integrity rules

12 Complete Manager Table
Just use 5 attributes and enter 3 records I give you

13 Enter Data in Project Table
Just use the 4 attributes and enter the 4 records I give you!

14 Populate the FK attribute: Referential Integrity Error
We will end up with a referential integrity violation

15 Referential Integrity
One of the FK attribute values in the Project Table (the M side of the relationship) does not exist in the parent table (the Manager Table – the one side of the relationship). There is NO manager ID , so that ID value cannot be assigned to a project Manager ID?

16 Referential Integrity and Tables
The specific value you enter for any FK attribute value must FIRST exist in the parent table Example: I cannot be assigned to teach a section of 141 (or any other class) if I am not first listed in the professor / teacher table You have a value for ManagerID that exists in the Manager table

17 Design Rules Normalization
A systematic process to control / reduce redundancy and improve integrity in a RDB that involves organize all data into tables and columns Minimize duplicate data Minimize or avoid data modification issues Simplify queries

18 Design Rules Normalization
Typically a trade-off between higher levels of normalization and processing speed As redundancy is reduced, the time it takes the DBMS to process a query or extract data can increase Higher levels of normalization may not always be desired where processing speed is critical

19 Design Rules We want to convert this single table DB file to a relational DBMS format

20 Design Rules There are clearly some redundancy issues with the data
How do we address redundancy via normalization and organize the data into relational tables?

21 Step 1 The current format is just an Excel worksheet, not a relational DBMS Identify attributes of each entity (or fields to be placed in each table)

22 Step 2 Create tables and columns (attributes) needed to capture all data in a relational format Attributes and data related to a specific entity in one table and attributes and data related to another entity in a different table Design tables to minimize need to enter redundant information What do we do with attributes that pertain to both employee and project?

23 Step 3 Consider relationship connectivity (1:M, M:M) – may be a trial and error process What type of relationship best captures the data relationships we have here? Can employees work on more than 1 project at a time, or only 1 project at a time? Is each project staffed by only 1 employee, or can each project be staffed my multiple employees? We can tell by looking at the data in the Excel table

24 Step 4 Draw the partial ERD

25 Summary Introduction to MS Access Normalization
Name and save a DB file Create tables and keys Create and enforce relationships Convert a partial ERD to design in Access Examples of both entity integrity and referential integrity using Access Normalization Example


Download ppt "Introduction to MS Access: creating tables, keys, and relationships"

Similar presentations


Ads by Google