DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula masiddula@mix.wvu.edu October 8, 2015.

Post on 17-Jan-2016

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

DAY 16:MICROSOFT ACCESS – CHAPTER 2

Madhuri Siddula

masiddula@mix.wvu.edu

October 8, 2015

TOPICS

• Single Table queries– Run the Query– Sort the query– Criteria on the query– Wildcards– Conditions on Numeric Data

• Multiple Table Queries

TABLE RELATIONSHIPS

• Access Databases are relational databases, they connect to each other tables through common fields.– Common fields are fields that contain the

same data in more than one table

• After you have a table for each subject in your database, you must provide a way to connect the data in the tables when you need meaningful information.

TABLE RELATIONSHIPS

• To connect the data in your tables, create common fields in related tables, and then define table relationships.– A relationship is an association established

between two tables based on common fields.– Once established, you create a query, a form,

or a report that displays information from more than one table.

CREATE TABLE RELATIONSHIPS

• Add tables to your relationships tab

CREATE TABLE RELATIONSHIPS

CREATE TABLE RELATIONSHIPS

• Create two relationships– MemberStates and Demographics– MemberStates and Economics

• Enable “Enforce referential integrity” and “Cascade update related fields”

• Disable “Cascade delete related fields”

QUERIES

• Query is:– Answers a question– Creates a subset of records, according to

your specifications

• Select query – database object that retrieves (selects) specific data from one or more tables

• Query design view – creates complex queries

CREATE A QUERY IN DESIGN VIEW

• Data source – table or tables where a query selects its data

ADD “DEMOGRAPHICS” TABLE

DISPLAY “MEMBER ID”, “CAPITAL” AND “POLITICAL SYS”

RUN THE QUERY AND SEE THE RESULTS

SORT THE QUERY• Sort the result by Member ID and then by Capital in

Ascending order.

• Remember, the sorts are applied from left to right, so any additional sorts must be applied to fields located to the right of your primary sort. If necessary, you can rearrange the fields by clicking the top of a field and dragging it to a new location.

CRITERIA ON QUERIES

• Display only Political Sys = “Republic”

USING WILDCARDS IN A QUERY

• Wildcard characters – serve as a placeholder for one or more unknown characters in the criteria.

• Use wildcard characters in place of the characters:– Asterisk (*) is a place holder to match one or

more characters.– Question mark (?) is a wildcard that is used to

search for unknown single characters.

USING WILDCARDS IN A QUERY

• Display records whose capital starts with either “S” or “N”.

USING WILDCARDS IN A QUERY

USING WILDCARDS IN A QUERY

• Also display records whose capital second letter in the name is “a”

USING WILDCARDS IN A QUERY

CONDITIONS ON NUMERIC DATA

• Add “Population” field to your query.• Display records where population is

greater than 50 million and less than 80 million.

SAVE THE QUERY

MULTIPLE TABLE QUERIES

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

MULTIPLE TABLE QUERIES

• Add two tables “Member States” and “Demographics” when creating a query.

RUN THE QUERY

THINGS TO DO

Create separate queries to provide the information requested below. Name each query after the step in which it appears (e.g., name the query in Step a as QueryA).

HINT: Run your queries to test them. Make sure that they display all and only the records that you would expect to appear.

• Specify criteriaa) Create a query that lists the ID, full name, capital, year of entry,

population, and political system of EU member states.i. Run the query to see the unrestricted results.

ii. Restrict the query to return records for only those member states that are Republics.

HINT: The query returns 18 records.

THINGS TO DO

b) 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.

HINT: The query returns 5 records.

THINGS TO DO

Sort query results

c) Create a copy of Query5B. Sort the results by GDP and then by name, both in descending order.

HINT: The query returns 5 records

Use wildcard operators

d) We wish to create a new query that lists all member countries whose names begin with “L” or “S”. We must also include countries where the second letter in the name is “R”. Display the member ID, full name, year of entry, and capital.

HINT: The query returns 10 records.

Thank you

top related