Download presentation
Presentation is loading. Please wait.
Published byJessie Lambert Modified over 9 years ago
1
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen aliya.farheen@mail.wvu.edu October 29,2015.
2
REMINDERS Homework # 4 is due on 10/30/2015 by 11:59 pm. MyITLab Lesson D is due on 11/2/2015 by 11:59 pm. Homework # 5 is due on 11/6/2015 by 11:59 pm. Start working on them !
3
CONTENTS Data Validation Techniques Importing and exporting data Using SQL in Access Exercises
4
Data Validation Techniques Importing and Exporting Data Using SQL in Access
5
DATA VALIDATION TECHNIQUES Data validation is a set of constraints or rules that help control how data is entered into a field. Those are Field Properties. Each Data type has its own properties. Let us see some frequently used Constraints or properties.
6
ESTABLISHING DATA VALIDATION Establish REQUIRED fields. Set DEFAULT VALUE for fields. Set VALIDATION RULE and generate VALIDATION TEXT. Use INPUT MASK wizard. Look up Fields. ( already done in homework's )
7
ESTABLISH REQUIRED FIELDS The required fields must not be left blank. Lets try Open blank table in design view Field 1 -> Student ID : Number Field 2 -> Student Name : Text and in Properties set “REQUIRED” to “YES” Switch to data sheet view and try to enter a record with out giving Student Name, you will see an error
8
SET DEFAULT VALUE FOR FIELDS. Delete the records first Switch to design view: Field 3 -> Score : Number Set DEFAULT VALUE property to 30 Observe records.
9
SET VALIDATION RULE AND GENERATE VALIDATION TEXT. Validation rule is designed to restrict the data values that can be entered into a field. Validation text informs users that the validation rule has been broken, and how to correct it. Lets try : Set validation rule and text for SCORE FIELD Delete all the records first and remove the default value set. Validation rule: [Score] <= 60 Validation Text: You can’t enter a value greater than 60. Please enter correct value. Now try to enter 90 in Score field for a record and observe the warning message.
10
USE INPUT MASK WIZARD. Input Mask Wizard generates an input mask for a field based on your answer to a few questions. Lets try: Delete all records Switch to Design view: Add a new field Phone Number: Text Note: works with Text/Date fields only Now click on Input Mask Wizard Option in Properties Choose Phone Number and go on……. Switch to Data Sheet view and try to add phone number and see what's happening.
11
Data Validation Techniques Importing and Exporting Data Using SQL in Access
12
IMPORTING DATA INTO ACCESS We can import data from Access / Excel / Text / XML file and more… Note for TEXT file : comma to next column and enter to next row. ( similarly to EXCEL)
13
EXPORTING DATA FROM ACCESS You can export the data from number of records in access to Excel / text / XML / PDF / Access files and more …… Try those ……
14
Data Validation Techniques Importing and Exporting Data Using SQL in Access
15
STRUCTURED QUERY LANGUAGE (SQL) Standard computer language for retrieving and updating data within database systems. Database applications like MS Access, DB2, MS SQL, Oracle, Sybase, MySQL, etc. use SQL. We have been using graphical tools to develop and manipulate database objects thus far…
16
SQL CONTINUED… Access has written the SQL statements behind the scenes for us. The SQL language can be separated into two sub sets: Data Manipulation Language (DML) and the Data Definition Language (DDL). We will look mostly at DML aspects.
17
SQL KEYWORDS 17
18
SELECT STATEMENT Retrieves all of the data in the fields specified from the specified database table. Syntax is: SELECT FROM – is a comma separated list of column names to be returned – is the tables where the are located…
19
SELECT STATEMENT The can be specified as *, which will return all columns that are in the. can also be aggregate functions (i.e sum, count, etc) Let’s try it!
20
LET’S TRY IT THE OLD WAY FIRST… Obtain and open Customer_orders.accdb Create a query in design view Add the Customer table only Add all fields Run the query Click “View” and change to “SQL View” to see what was done behind the scenes…
21
SELECT EXERCISE Close the Query without saving changes Create a new query in design view. Don’t add any tables Change to “SQL View” Type SELECT * FROM customer Run the query by clicking “!”… Words in capital are “reserved words”
22
SELECT EXERCISE Now, let’s revise our SQL SELECT… Go back to SQL View and make it read: SELECT first_name, last_name FROM customer Run the Query We are shown only the fields we requested from the table we told it to use…
23
ONE MORE… Say we wanted to have it ALIAS a column for us which combined first and last name field values and separated them with a space… SELECT (first_name + “ ” +last_name) AS [Full Name] FROM customer Run it! We are presented a field that does not actually exist in the table as we gave it as alias.
24
Open the database on the Lecture notes for today and complete the exercises.
25
EXERCISE-01 Create a new query to summarize the fatalities data. For each region, list the full region name, the count of countries in the region, the sum of the population, and the sum of estimated fatalities. Sort by region name in ascending order. HINT: This query will show 8 records and 4 fields
26
EXERCISE-02 We wish to create a query that will list countries where a plurality of fatalities were from cars and trucks. For this query copy-and-paste the below SQL code: SELECT Countries.CountryName, Fatalities.EstimatedFatalities, Fatalities.CarPctg FROM Countries INNER JOIN Fatalities ON Countries.CountryAbbrv = Fatalities.CountryAbbrv WHERE (((Fatalities.CarPctg)>[Fatalities].[MotorcyclePctg] AND (Fatalities.CarPctg)>[Fatalities].[BicyclePctg] AND (Fatalities.CarPctg)>[Fatalities].[PedestrianPctg] AND (Fatalities.CarPctg)>[Fatalities].[UnknownPctg])); IMPORTANT: Do not make any modifications to the query other than entering the above SQL code. HINT: This query will show 70 records and 3 fields.
27
EXERCISE-03 Create a new query that lists each country’s name, the full name of its region, the number of estimated fatalities, and the percentage of fatalities involving pedestrians, and its GDP per capita. You can calculate the GDP per capita using the formula: [. ] [. ] Only display records where the percentage of accidents involving pedestrians is greater than 0% (> 0). Format the GDP per capita as currency with no decimal places. Sort by the percentage of fatalities involving pedestrians then by the GDP per capita, both in descending order. HINT: This query will show 107 records and 5 fields.
28
EXERCISE-04 We wish to compare statistics for countries in South America versus those in Asia. Display each country’s full name, its population, GDP, number of estimated fatalities, and the percentages of fatalities involving cars, involving motorcycles, involving bicycles, involving pedestrians, and involving other or unknown victims. Only display records for countries in the South America or Asia regions. Do not show the region in the result. HINT: This query will show 23 records and 9 fields.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.