47
Mgt 240 Lecture Mgt 240 Lecture MS Excel and Access: MS Excel and Access: Introduction to Databases Introduction to Databases September 23, 2004 September 23, 2004

Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Mgt 240 LectureMgt 240 Lecture

MS Excel and Access:MS Excel and Access:

Introduction to DatabasesIntroduction to Databases

September 23, 2004September 23, 2004

Page 2: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

MiscellaneousMiscellaneous

Homework 3 grades posted Friday or SaturdayHomework 3 grades posted Friday or Saturday Homework 4 due next Friday, 10/1/04, by 5pmHomework 4 due next Friday, 10/1/04, by 5pm Posted grade spreadsheets and scrolling to Posted grade spreadsheets and scrolling to

see commentssee comments Grading questions – review question in Grading questions – review question in

homework before asking what you did wrong!homework before asking what you did wrong! Please use a different name for your turned in Please use a different name for your turned in

homework than the original homework name – homework than the original homework name – that way you’re more likely to turn in the right that way you’re more likely to turn in the right filefile

Page 3: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Today’s ObjectivesToday’s Objectives

Introduction to DatabasesIntroduction to Databases Excel database capabilitiesExcel database capabilities Relational databasesRelational databases

AccessAccess

Page 4: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Database DefinitionDatabase Definition

An integrated collection of data An integrated collection of data that is organized to meet the that is organized to meet the informational needs of multiple informational needs of multiple users in an organizationusers in an organization

Database examplesDatabase examples

Page 5: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Traditional Approach To Data The Traditional Approach To Data ManagementManagement

Page 6: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Database Approach to Data The Database Approach to Data ManagementManagement

Page 7: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Hierarchy of DataThe Hierarchy of Data

Page 8: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Field, Record, TableField, Record, Table

FieldField - a single characteristic or attribute of a person, place, object, event or idea (column)

RecordRecord - a collection of field values (row)

TableTable - a collection of records

Page 9: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Keys and AttributesKeys and Attributes

Page 10: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Excel DatabasesExcel Databases

Page 11: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Using Excel to Create Using Excel to Create DatabasesDatabases

Databases are called “Lists” in ExcelDatabases are called “Lists” in Excel Excel provides features that allow you to maintain Excel provides features that allow you to maintain

lists of information such as customer lists, lists of information such as customer lists, telephone lists, inventory lists, and so on. telephone lists, inventory lists, and so on.

An Excel list is a collection of rows and columns An Excel list is a collection of rows and columns that contain similar data.that contain similar data.

In a worksheet, each column represents a field of In a worksheet, each column represents a field of data and each row represents a record of data. data and each row represents a record of data.

The first row of the list always contains the name The first row of the list always contains the name of the fields and is called a field header row.of the fields and is called a field header row.

Page 12: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

An example of an Excel listAn example of an Excel list

Gourmet.xls

Page 13: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Freeze rows and columnsFreeze rows and columns When you scroll through large amounts of data in a When you scroll through large amounts of data in a

worksheet, you can move data off the screen. worksheet, you can move data off the screen. If you prefer to have portions of data remain on the If you prefer to have portions of data remain on the

screen at all times, such as the column and/or row screen at all times, such as the column and/or row headings, you can freeze a portion of the list so that it headings, you can freeze a portion of the list so that it remains while the rest of the data scrolls.remains while the rest of the data scrolls.

To freeze rows and columns:To freeze rows and columns: Click in a cell to select itClick in a cell to select it Click Window on the menu bar, and then click Click Window on the menu bar, and then click

Freeze Panes to freeze the rows above the selected Freeze Panes to freeze the rows above the selected cell, and the columns to the left of the selected cellcell, and the columns to the left of the selected cell

Excel will display dark vertical and horizontal lines Excel will display dark vertical and horizontal lines to indicate the rows and columns that are frozento indicate the rows and columns that are frozen

Page 14: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

A frozen datasheetA frozen datasheet

Gourmet.xlsGourmet.xls

Page 15: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Find and replace values in a Find and replace values in a worksheetworksheet

The Find command allows you to search The Find command allows you to search through the data in a worksheet for a through the data in a worksheet for a particular character string. particular character string.

Optionally, you can choose to replace the Optionally, you can choose to replace the character string with another string. character string with another string.

This procedure is called Find and Replace. This procedure is called Find and Replace. For example, you might want to find every For example, you might want to find every

occurrence of ACCT and replace it with occurrence of ACCT and replace it with Accounting Accounting

Page 16: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Find and Replace dialog The Find and Replace dialog boxbox

Gourmet.xls

Page 17: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Sort data in a listSort data in a list

Excel makes it easy to sort a list in Excel makes it easy to sort a list in ascending or descending order based ascending or descending order based on any field(s) in the list.on any field(s) in the list.

The field(s) selected on which to sort The field(s) selected on which to sort are called the sort fields or the sort are called the sort fields or the sort keys. keys.

You may choose to sort the data on a You may choose to sort the data on a single field or on a collection of fields.single field or on a collection of fields.

Page 18: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Sort using a single sort keySort using a single sort key

Gourmet.xls

Page 19: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Sort using multiple keysSort using multiple keys

Gourmet.xls

Page 20: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Use a data form to enter, Use a data form to enter, search for, edit, and delete search for, edit, and delete

recordsrecords Sometimes it is easier to view the data in Sometimes it is easier to view the data in

a list through a data form.a list through a data form. A data form is a dialog box that you can A data form is a dialog box that you can

use to arrange data to view one record at use to arrange data to view one record at a time. a time.

You can use the data form to display You can use the data form to display records, to search for records, to modify records, to search for records, to modify records, and to delete records from the records, and to delete records from the Excel list.Excel list.

Page 21: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

An Excel data formAn Excel data form

Gourmet.xls

Page 22: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Filter data in a list using Filter data in a list using AutoFiltersAutoFilters

Sometimes you will want to see a portion of the Sometimes you will want to see a portion of the records instead of all of them.records instead of all of them.

The process of displaying only those records The process of displaying only those records that meet some criteria is called Filtering. that meet some criteria is called Filtering.

When data in the list is filtered, records that do When data in the list is filtered, records that do not meet your criteria are hidden. not meet your criteria are hidden. These records are not removed from the list and, These records are not removed from the list and,

therefore, can be redisplayed by removing the filter therefore, can be redisplayed by removing the filter Simple filters can be specified by clicking the Simple filters can be specified by clicking the

list arrow on any field name cell.list arrow on any field name cell. More complex filters must be created using the More complex filters must be created using the

Custom AutoFilters option.Custom AutoFilters option.

Page 23: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

AutoFilter optionsAutoFilter options

Gourmet.xls

Page 24: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Apply conditional formatting Apply conditional formatting

to a rangeto a range There are times when you will want data to have a There are times when you will want data to have a

different appearance if it meets some criteria. different appearance if it meets some criteria. For example, you might want data to appear in For example, you might want data to appear in

red, if the data is more than six months old red, if the data is more than six months old Or, you might want a value to be black if it is Or, you might want a value to be black if it is

positive and red if it is negative positive and red if it is negative This kind of formatting is called conditional This kind of formatting is called conditional

formatting.formatting. You specify the condition under which you want the You specify the condition under which you want the

formatting to take place and what the formatting formatting to take place and what the formatting should be.should be.

Page 25: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Conditional Formatting The Conditional Formatting dialog boxdialog box

Gourmet.xls

Page 26: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Insert subtotals into a listInsert subtotals into a list

The data in a list can be summarized by adding The data in a list can be summarized by adding subtotals to the list. subtotals to the list.

You can include summary information such as a You can include summary information such as a count, a sum, an average, a minimum value, and count, a sum, an average, a minimum value, and or a maximum value. or a maximum value.

When the Subtotals command is applied to the list, When the Subtotals command is applied to the list, a subtotal row is automatically added to the list. a subtotal row is automatically added to the list.

You can specify that you want the subtotal(s) to You can specify that you want the subtotal(s) to apply to the worksheet and/or groups within the apply to the worksheet and/or groups within the worksheet.worksheet.

Page 27: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

The Subtotal dialog boxThe Subtotal dialog box

Gourmet.xls

Page 28: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

An Excel datasheet with An Excel datasheet with totals addedtotals added

Page 29: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Use the subtotals outline Use the subtotals outline viewview

Previously you learned about creating Previously you learned about creating subtotal lines within a worksheet.subtotal lines within a worksheet.

Sometimes, it might be more beneficial Sometimes, it might be more beneficial to view the summary information only.to view the summary information only.

You can do this by displaying the data You can do this by displaying the data in Subtotals Outline View. in Subtotals Outline View.

You may choose from Level 1, Level 2, You may choose from Level 1, Level 2, and Level 3 outline view.and Level 3 outline view.

Page 30: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Totals displayed in Outline Totals displayed in Outline viewview

Gourmet.xls

Page 31: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

When to Use Excel for a When to Use Excel for a DatabaseDatabase

Use Excel when you:Use Excel when you: Require a flat or Require a flat or non-relationalnon-relational view of your view of your

data (you do not need a relational database data (you do not need a relational database with multiple tables). with multiple tables).

This is especially true if that data is mostly This is especially true if that data is mostly numericnumeric—for example, if you want to maintain a —for example, if you want to maintain a financial budget for a given year.financial budget for a given year.

Want to run primarily Want to run primarily calculationscalculations and and statistical comparisonsstatistical comparisons on your data—for on your data—for example, if you want to show a cost/benefit example, if you want to show a cost/benefit analysis in your company's budget. analysis in your company's budget.

Know your Know your dataset is manageable in sizedataset is manageable in size (no more than 15,000 rows). (no more than 15,000 rows).

Page 32: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Access DatabasesAccess Databases

Page 33: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Data RedundancyData RedundancyA problem that occurs when a database is set up inefficiently.

Leads to data entry errors.

This example illustrates a “flat file” (like an Excel list) with redundant data.

This table would be better divided into two tables containing “like” data -- Customer Information and Order Information.

This process is called Data Normalization.

Gourmet.xls

Page 34: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Normalizing Gourmet.xlsNormalizing Gourmet.xls

Reduce redundancy in dataReduce redundancy in data Logically organize data into separate, distinct Logically organize data into separate, distinct

entitiesentities Separate objects, people, eventsSeparate objects, people, events

Specify relationships between entitiesSpecify relationships between entities Gourmet.xlsGourmet.xls

How many separate entities can you identify in this file?How many separate entities can you identify in this file?

Page 35: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Fields in Entities in Gourmet.xlsFields in Entities in Gourmet.xls

CustomerCustomer CompanyNameCompanyName CountryCountry

Page 36: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Relationships between Entities in Relationships between Entities in Gourmet.xlsGourmet.xls

Customer

Company NameCountry

Product

Product NameCategoryUnitPrice

SalesRep

Sales Rep

OrderOrderDateQuantityDiscountFreight

Shipper

Shipper

Page 37: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Primary Keys in Entities in Primary Keys in Entities in Gourmet.xlsGourmet.xls

Customer

Company Name *Country

Product

Product Name *CategoryUnitPrice

SalesRep *

Sales Rep

OrderOrderDateQuantityDiscountFreight

Shipper

Shipper *

Page 38: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Foreign Keys in Entities in Foreign Keys in Entities in Gourmet.xlsGourmet.xls

Customer

Company Name *Sales Rep **Country

Product

Product Name *CategoryUnitPrice

SalesRep *

Sales Rep

OrderProduct Name **Company Name **OrderDate *QuantityDiscountFreightShipper ** Shipper

Shipper *

CombinedPrimary Key

Page 39: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Primary & Foreign KeysPrimary & Foreign Keys

Primary Key Field:

A field whose value uniquely identifies each record in the table

Foreign Key Field:

A primary key field from one table placed in a second table to form a relationship between the tables

Page 40: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Relational database and Relational database and keyskeys

A relational database is a collection of A relational database is a collection of tables that are related to one another tables that are related to one another based on a common field.based on a common field.

A field, or a collection of fields, is A field, or a collection of fields, is designated as the primary key. designated as the primary key. The primary key uniquely identifies a record The primary key uniquely identifies a record

in the table. in the table. When the primary key of one table is When the primary key of one table is

represented in a second table to form a represented in a second table to form a relationship, it is called a foreign key.relationship, it is called a foreign key.

Page 41: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Relational Database ModelRelational Database Model

Page 42: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Creating a Relational Database Creating a Relational Database in Access in Access

Create tables in design viewCreate tables in design view Specify fieldsSpecify fields

Make sure to include foreign keysMake sure to include foreign keys Specify primary keySpecify primary key Gourmet.mdbGourmet.mdb

Page 43: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

What is an Access query?What is an Access query? If you want to see just a portion of the data in a If you want to see just a portion of the data in a

table or tables you can create a query. table or tables you can create a query. A query is a question you ask about the data stored A query is a question you ask about the data stored

in a database table or tables.in a database table or tables. Access responds by displaying the data according Access responds by displaying the data according

to your question. to your question. For example, if you ask to see all the customers For example, if you ask to see all the customers

from New York, the response would be to display from New York, the response would be to display only the records whose state field matches with only the records whose state field matches with NYNY

Gourmet.mdbGourmet.mdb

Page 44: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Linking Database Tables Linking Database Tables to Answer a Queryto Answer a Query

Page 45: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

When to Use Access for a When to Use Access for a DatabaseDatabase

Require a Require a relationalrelational database (multiple tables) to store database (multiple tables) to store your data. your data.

May need to May need to add more tablesadd more tables in the future to an originally in the future to an originally flat or non-relational data set. flat or non-relational data set.

Have a Have a very large amount of datavery large amount of data (thousands of entries). (thousands of entries). Have data that is mostly of the Have data that is mostly of the long text string typelong text string type (not (not

numbers or defined as numbers). numbers or defined as numbers). Rely on Rely on multiple external databasesmultiple external databases to derive and to derive and

analyze the data you need. analyze the data you need. Need to maintain Need to maintain constant connectivityconstant connectivity to a large to a large

external database such as one built with Microsoft SQL external database such as one built with Microsoft SQL Server. Server.

Want to run Want to run complex queriescomplex queries. . Have Have many people workingmany people working in the database and want in the database and want

robust options to expose that data for updating. robust options to expose that data for updating.

Page 46: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

More Access Resources More Access Resources from Microsoftfrom Microsoft

Using Access or Excel to manage your datUsing Access or Excel to manage your dataa

Sample Access databases that you Sample Access databases that you can download and adaptcan download and adapt

About Access databasesAbout Access databases About designing a databaseAbout designing a database Description of the database Description of the database

normalization basicsnormalization basics Roadmap to Access 2003 trainingRoadmap to Access 2003 training

Page 47: Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004

Assigned ReadingAssigned Reading

Work through Tutorial 5 (pp. 195-225) in Excel 2003 textWork through Tutorial 5 (pp. 195-225) in Excel 2003 text Following are the tasks you should be able to perform using Following are the tasks you should be able to perform using

Excel’s list features:Excel’s list features: Freeze rows and columnsFreeze rows and columns Use find and replaceUse find and replace Create a list rangeCreate a list range Sort dataSort data Maintain a listMaintain a list Use a data formsUse a data forms Filter a listFilter a list Use conditional formattingUse conditional formatting Use the total row to calculate totals in a listUse the total row to calculate totals in a list Insert subtotals into a listInsert subtotals into a list Use the subtotals outline viewUse the subtotals outline view