ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries...

Post on 24-Dec-2015

220 views 2 download

Tags:

Transcript of ACCESS TABLES & QUERIES. OBJECTIVES Create tables Establish table relationships Create queries...

ACCESS TABLES & QUERIES

2

OBJECTIVES

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

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

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

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

6

DATA TYPESNotice Yes/No and Lookup Wizard

7

EXAMPLE

• Download the file European_Union database

• Rename the file as lastname_firstname_eu.accdb.

8

LETS CREATE OUR FIRST TABLE

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

data type as Text

9

10

ENTER DATA INTO TABLE

11

PRIMARY KEYS

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

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.

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.

14

15

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.

17

18

19

QUERY3-FROM QUERY2

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

20

21

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