introduction to access bus 782. access objects tables –open –design –new –wizard queries...

31
Introduction to Access BUS 782

Post on 21-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Introduction to Access

BUS 782

Page 2: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Access Objects

• Tables– Open– Design– New– Wizard

• Queries• Forms• Reports• Pages

Page 3: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Creating a Table

• Create table in design view– Field name– Field data type

• Create table by using wizard

• Create a primary key

• Enter data

Page 4: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Demo

• Queries

• Forms

Page 5: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Querying Database

ISYS 363

Page 6: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Basic Query Language Operations

• Selection

• Projection

• Join

• Aggregates: Max, Min, Sum, Avg, Count– Totals and SubTotals– GroupBy

• Calculated fields

Page 7: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Selection

• Selection operation retrieves records that satisfy user’s criteria.

Page 8: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Projection

• Projection operation defines a vertical subset of a table and retrieves only the specified fields.

Page 9: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Natural Join

• The two tables must have common attributes:– Key and foreign key.

• Combines two tables to form a new table where records of the two tables are combined if the common attributes have the same value.

Page 10: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Join Example

Faculty File: FID FnameF1 ChaoF2 Smith

Student File:SID Sname FIDS1 Peter F1S2 Paul F2S3 Smith F1

Faculty Join Student =

Note: What if FID is named AdvisorID?

Page 11: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Join Example

Student File:SID Sname FIDS1 Peter

F1S2 Paul

F2S3 Smith

F1

StudentCourse File:SIDCIDS1ISYS263

S1Acct101S3ISYS363S2ISYS263S2Fin350S2Acct101

Course File:CID Cname

UnitsISYS263 IS IntroPeter

3ISYS363 MIS IntroPaul

3Acct101 accounting

3Fin350 Finance Intro

3

(Student Join StudentCourse) Join Course

Page 12: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Aggregate Functions

• Max, Min, Sum, Count, Avg

• View/Totals

• Ex. Student: SID,Sname, GPA, Sex, Major– How many students in this University?– What is the overall average GPA?

Page 13: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Aggregates by Group

– How many students in each major?– Compare male students and female students

average GPA.

Page 14: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Examples

• Customer: CID, Cname, City, Rating• Orders: OID, Odate, SalesPerson, CID• Queries:

– Find customers live in San Francisco.– Produce a customer report that shows CID, Cname,

and Rating.– Number of customers in each city

• City, NumbeOfCustomers

– Produce a report that shows the number of orders for each customer:

• CID, Cname, TotalNumberOfOrders

Page 15: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Examples

• University Database:– Student, StudentCouse, Course– Minimum enrollment example.

• Order Processing Database:– Customer, Orders, OrderDetail, Product– MIS report– Total amount for each order– Criteria applied to subtotal

Page 16: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Calculated Fields

• Rename a field:– NewName:OldName

• Define a calculated field:– Tax:salary*.15– Age:Year(Now()) – Year(DOB)– Amount:qty*price– IIF function

• Calculated field based on subtotal:– University tuition rules:

• If total units < 5 then tuition= 600• Otherwise tuition =600 + 200 for each additional unit

Page 17: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Criteria

• >, >=, <, <=, =, <>

• Range: BETWEEN 1/1/03 AND 12/31/03

• Wildcard:– ? – match any one character

• “K?NG”

– * - Match any number of characters• “C*”

Page 18: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Complex Condition

• University admission rules: Applicants will be admitted if meet one of the following rules:– 1. Income >= 100,000– 2. GPA > 2.5 AND SAT > 900

• An applicant’s Income is 150,000, GPA is 2.9 and SAT is 800. Admitted?– Income >= 100,000 OR GPA > 2.5 AND SAT >900

• How to evaluate this complex condition?

Page 19: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

• Scholarship: Business students with GPA at least 3.2 and major in Accounting or CIS qualified to apply:– 1. GPA >= 3.2– 2. Major in Accounting OR CIS

• Is a CIS student with GPA = 2.0 qualified?– GPA >= 3.2 AND Major = “Acct” OR Major = “CIS”

• Is this complex condition correct?

Page 20: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Complex condition

• Rating = “A” OR Rating = “B”

• Cname = “Chao” OR Cname = “Smith”• Rating = “A” OR Rating = “B” AND City=“SF”• (Rating = “A” OR Rating = “B”) AND City=“SF”

Page 21: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Sorting

• One field sorting

• Two fields sorting

Page 22: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Other Queries

• Update query

• Delete query

• Parameter query

• CrossTab query

Page 23: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Forms

• Form wizard

• Main/Sub Form– Based on two tables with 1:M– Based on a query created from two tables

with 1:M

• Pivot Table form– AutoCal

Page 24: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Access Tools for Import/Export

• File/Get External Data

• File/Export

Page 25: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Excel’s Database Tools

• Data– Sort– Filter– Subtotals– Pivot table/Pivot chart

• OLAP: On Line Analytical Process• DrillDown, RollUp, ReAggregation

– Import external data• Import data• New web query• New database query

Page 26: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Data/Import External Data

• New Database Query

• Select <New Data Source> and click OK.

Page 27: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

OLAP Cube• Data/Import External Data/New database query:

– Define query– In the last step, choose Create OLAP Cube

Page 28: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

OLAP Wizard

• Source of data to be summarized

• Analysis dimensions

Page 29: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Web Query

• Data/Import External Data/New web query• Click table on the web page • Use the Save Query button to save web query• Web query can be refreshed. Copy/Paste can

not.

Page 30: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Import Data

• Data/Import External Data/Import Data

Page 31: Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages

Data Consolidation

• Help, F1