access tables & queries. objectives create tables establish table relationships create queries...

22
ACCESS TABLES & QUERIES

Upload: jesse-murphy

Post on 24-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

ACCESS TABLES & QUERIES

Page 2: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

2

OBJECTIVES

• Create tables• Establish table relationships• Create queries• Specify criteria for different data types• Compact & Repair Database

Page 3: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

3

CREATE TABLES

• Create fields in Design View• Import data from another database or

application– Examples: Excel spreadsheets or Word text

files

• Enter data directly into rows in Datasheet views

Page 4: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

4

FIELDS IN TABLES

• Field names should be meaningful!• Access uses CamelCase notation

• Use uppercase letters for each first letter of each new word

• Example: ProductCost

Page 5: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

5

FIELD DATA TYPES

• Every field has a data type • Determines:

– The type of data that can be entered – The operations that can be performed on that

data

• Access recognizes 10 data types

Page 6: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

6

DATA TYPESNotice Yes/No and Lookup Wizard

Page 7: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

7

EXAMPLE

• Download the file European_Union database

• Rename the file as lastname_firstname_eu.accdb.

Page 8: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

8

LETS CREATE OUR FIRST TABLE

• Create a table named MemberStates• Fields are MemberID and Member with

data type as Text

Page 9: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

9

Page 10: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

10

ENTER DATA INTO TABLE

Page 11: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

11

PRIMARY KEYS

Designate appropriate primary keys• MemberStates: MemberID • Demographics: MemberID • Economics: CountryID

Page 12: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

12

RELATIONSHIPS

Create appropriate relationships between• MemberStates and Demographics • MemberStates and Economics

• Enforce referential integrity and enable

cascade updates, but do not enable cascade deletes.

Page 13: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

13

QUERY1

Create a query that lists the ID, full name, capital, year of entry, population, and political system of EU member states. • Run the query to see the unrestricted

results. • Restrict the query to return records for

only those member states that are Republics.

Page 14: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

14

Page 15: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

15

Page 16: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

16

QUERY2-QUERY WITH OPERATORS

Create a new query that lists the full name, GDP, employment rate, and population of member states.

Only display states where the population is greater than 50 million and the employment rate is 60% or higher. Member states with GDP greater than 900 should be included irrespective of the population and employment rate.

Page 17: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

17

Page 18: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

18

Page 19: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

19

QUERY3-FROM QUERY2

• Create a copy of Query2. Sort the results by GDP and then by name, both in descending order.

Page 20: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

20

Page 21: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

21

Page 22: ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries Specify criteria for different data types Compact & Repair

COMPACTING & REPAIRING A DATABASE

• Access databases increase in size over time

• Compacting – Avoids loss of data– Recovers unclaimed space– Defragments fragmented databases– Repairs corrupt databases