Tutorial 3 Queries and Table Relationships

Slides:



Advertisements
Similar presentations
Access Manual 4 By Elham S.Khorasani Ismail Guneydas Dhawala Kovuri.
Advertisements

Pasewark & Pasewark Microsoft Office XP: Introductory Course 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
Concepts of Database Management Seventh Edition
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
SUNY Morrisville-Norwich Campus-Week 10 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
COMPREHENSIVE Access Tutorial 2 Building a Database and Defining Table Relationships.
Querying a Database Microsoft Office Access 2003.
FIRST COURSE Access Tutorial 2 Building a Database and Defining Table Relationships.
QUERYING A DATABASE By: Dr.Ennis-Cole. OBJECTIVES: Learn how to use the Query window in Design view Create, run and Save queries Define a relationship.
Define Table Relationships—1 of 3 One of the most powerful features of a relational database management system, such as Access, is its ability to define.
Chapter 3 Maintaining a Database
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Unit J: Creating a Database Microsoft Office Illustrated Fundamentals.
Introduction to Access By Mary Ann Chaney and Alicia Harkleroad.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
Microsoft Access – Tutorial 3
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
DAY 14: ACCESS CHAPTER 1 Tazin Afrin October 03,
Chapter 6 Advanced Report Techniques
® Microsoft Office 2013 Access Building a Database and Defining Table Relationships.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
 A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. What is Database?
CSS/417 Introduction to Database Management Systems Workshop 2.
Analyzing Data For Effective Decision Making Chapter 3.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
® Microsoft Office 2010 Access Tutorial 2 Building a Database and Defining Table Relationships.
IE 423 – Design of Decision Support Systems Database development – Relationships and Queries.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
® Microsoft Access 2010 Tutorial 2 Building a Database and Defining Table Relationships.
Access Chapter 2: Relational Database Objectives Design data Create tables Understand table relationships Understand data types, key, & field properties.
® Microsoft Office 2010 Building a Database and Defining Table Relationships.
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making Chapter.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
Microsoft Access 2010 Chapter 3 Maintaining a Database.
Tutorial 4 Forms and Reports Review Assignment pp 4.34 to 4.35.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Access Tutorial 2 Building a Database and Defining Table Relationships
New Perspectives on Microsoft Access 2016
Microsoft Access – Tutorial 3
Objectives Query for top values Create a parameter query
and Defining Table Relationships
Microsoft Office Illustrated Fundamentals
Microsoft Access 2003 Illustrated Complete
Microsoft Office Access 2003
Tutorial 3 – Querying a Database
Microsoft Office Access 2003
Access Tutorial 2 Building a Database and Defining Table Relationships
Access Tutorial 2 Building a Database and Defining Table Relationships
Nagendra Vemulapalli Access chapters 3&6 Nagendra Vemulapalli
New Perspectives on Microsoft
Presentation transcript:

Tutorial 3 Queries and Table Relationships Review Assignment pp 3.42 to 3.43

Queries Simple queries extract information from a single table Complex queries extract information from multiple tables Based on “relations” between tables

Development Standards - Queries Two purposes for queries Display information to end-users The name of the query must informative (since the end user will select the query from a list) and the displayed column names should be grammatically correct (use captions) Process data or prepare data for a report Typically, these queries should have a special prefix to separate them from other queries.

Step 2: Students from Ireland Table: Student Fields: StudentID, FirstName, LastName Sort – ascending by LastName Criteria: Nation value is “Ireland” (not displayed) Save as: Students from Ireland Include spaces in name

Step 3 Use query to update record Note: Access queries are dynamic Find Student ID: OMA9956 Change first name to Richard

Access is a relational database A database is almost always a collection of tables. Access is a relational database management system that allows you to form relationships between the tables. When you form a relationship between tables, you are joining the tables. Tables are joined on common fields between the tables. When tables are joined, you can view data from both tables as if the tables were one combined table.

A one-to-many relationship Tables can be joined in two (not three) ways: one-to-one one-to-many A one-to-many relationship exists when one table has many records associated with a given value but the related table has only one record for that value. The table with one record is called the primary table The table with many records is called the related table Queries can be defined to use the relationship to extract data from both tables in a single query.

An example of a one-to-many relationship The Employer table is related to the Position table via the common field EmployerID. The Employer table has one record for EmployerID value 10126. The Position table has two records.

Table Relationships Establish “Referential” integrity between tables Link “primary key” field in primary table to related field in the related table When you add a record to the related table, the value in the related field must already exist in the primary table When add a record to Student, the value entered in the SSN field must already exist as a value in the SSN field of Recruiter

Using referential integrity When dealing with related tables, you need to decide if you want to enforce referential integrity. Referential integrity allows you to maintain the integrity between related tables. The rules associated with referential integrity specify that when you add a record to a related table, there must be a matching record in the primary table. If you choose to enforce referential integrity, you can insure that you will not have orphaned records (records that have no matching record in the primary table).

Table Relationships – cont’d In Access, have option to cascade update and delete. Cascade update: if change value of SSN field in Recruiter, will automatically update values in the SSN field of Student Cascade delete: if delete a record in Recruiter, will automatically delete all related records in Student (not the value in the SSN field, but the entire student record)

Use cascaded updates and cascaded deletes In addition to referential integrity, you can also tell Access to implement cascaded updates and cascaded deletes. If you choose cascaded updates, making a change in a field that is common to two related tables will cause the update to be made in both tables. Cascade deletes is similar. If you delete a field that is common to two tables, the deletion will take place in both tables. You should carefully consider whether you want to implement these features, as they can have dramatic effects on your data.

Step 4 Define relationship between Student and Recruiter Common field is SSN NOTE: plus signs in Recruiter reflect “Join”

Step 5: Wolfe Recruits Tables: Recruiter & Student Fields FirstName, LastName, City, Nation from Student BonusQuota, Salary from Recruiter SSN from Student Sort: Ascending by Nation Criteria: SSN = 977071798 (do not display SSN) Resize columns

Logical Operations in Criteria

Step 9: Bonus Info Table: Recruiter Fields: all except SSN Criteria: BonusQuota between 40 and 50 Between operator is inclusive: 40 <= BonusQuota <= 50 Could also use logical operators >= 40 and <= 50 Salary > 35,000

Step 10: Salaries with Raises Open Bonus Info query in design view Use Expression Builder to show net amount of 3 percent raise Label – Everything before the colon is part of the label RaiseAmt: Formula – start with =, then select fields and operators =[Salary]*0.03

Step 10: Salaries with Raises (cont’d) Format RaiseAmt using field properties Set the caption to "Raise Amount" Set the format to Standard Set the decimal places to 2 Use Save As to save the query

Step 11: Students from Holland Plus Younger Students Copy Students from Ireland – rename when paste. Modify to: Criteria: Nation of Holland (and show nation) BirthDate: > 1/1/84 Note: Access uses # to denote a date value (similar to using quotes to denote a text value)

Using Aggregate Functions Access has several Aggregate Functions that can be used to calculate various statistical information. Aggregate functions are specified in the Total row of the design grid. They can be assigned by clicking the Totals button on the Query Design toolbar.

Step 12: Salary Statistics Table: Recruiter Field: Salary (three times) Totals: Min, Max, Avg Labels: LowestSalary HighestSalary AverageSalary Also add captions

Step 13: Salary Statistics by BonusQuota Open Salary Statistics in design mode Add BonusQuota field – move to first column Total should be GroupBy Use the Save As option