Top Banner
DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula [email protected] October 8, 2015
35

DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula [email protected] October 8, 2015.

Jan 17, 2016

Download

Documents

Leon Henderson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula masiddula@mix.wvu.edu October 8, 2015.

DAY 16:MICROSOFT ACCESS – CHAPTER 2

Madhuri Siddula

[email protected]

October 8, 2015

Page 2: 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

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

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.

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

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.

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

CREATE TABLE RELATIONSHIPS

• Add tables to your relationships tab

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

CREATE TABLE RELATIONSHIPS

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

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”

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

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

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

CREATE A QUERY IN DESIGN VIEW

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

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

ADD “DEMOGRAPHICS” TABLE

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

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

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

RUN THE QUERY AND SEE THE RESULTS

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

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.

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

CRITERIA ON QUERIES

• Display only Political Sys = “Republic”

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

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.

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

USING WILDCARDS IN A QUERY

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

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

USING WILDCARDS IN A QUERY

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

USING WILDCARDS IN A QUERY

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

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

USING WILDCARDS IN A QUERY

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

CONDITIONS ON NUMERIC DATA

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

greater than 50 million and less than 80 million.

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

SAVE THE QUERY

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

MULTIPLE TABLE QUERIES

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

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

MULTIPLE TABLE QUERIES

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

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

RUN THE QUERY

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

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.

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

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.

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

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.

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

Thank you