56
Succeeding in Business with Microsoft Access 2013 Building The Database Chapter 2

Ch02 cmpt110

Embed Size (px)

Citation preview

Page 1: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Building The Database

Chapter 2

Page 2: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Chapter Introduction

• Learn different techniques for:– Creating tables – Entering data – Verifying data– Relating tables– Documenting database objects – Backing up database– Repairing database– Securing data

2

Page 3: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Tools Covered in This Chapter

• Database Documenter• Database security• Datasheet view• Design view• Import Spreadsheet Wizard

3

• Input Mask Wizard• Lookup Wizard• Relationships window• Subdatasheet

Page 4: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Level 1 Objectives: Creating the Database Tables

• Review the database design• Create the database tables using the database

design• Work in Design view

4

Page 5: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 5

Creating the Database Tables:Reviewing the Database Design

• Make sure that the database stores data in the correct format and outputs the correct queries, forms, and reports

• Analyze the client’s needs and make sure the design is easy to understand

• Limit the scope of a new system

Page 6: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 6

Page 7: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating the Database Using the Database Design

• Start Access click New tab in the navigation bar on the File tab

• Database window – Main control panel for database

• Navigation pane– Located on the left side of the window– Lists all objects (tables, reports, etc.) in the

database

7

Page 8: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating a Table by Entering Data in Datasheet View

• Datasheet view– Shows table’s records in rows and table’s fields in

columns• Table window– Indicates table’s name

• Just start entering data• Access adds ID field to datasheet

8

Page 9: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Datasheet View

9

Page 10: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating a Table by Entering Data in Datasheet View (cont’d.)

• Click save button– Save as dialog box– Enter table name

• Change to design view– Click view button in Views group on the Home tab

10

Page 11: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Working in Design View

• Design view– Define table’s fields and field properties – Rearrange order of fields as necessary

• Table design grid– Top part of design view– Includes Field Name, Data Type, and Description

columns– Each row • Field in table

11

Page 12: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 12

Working in Table Design View (cont’d.)

• Field properties pane– Bottom part of design view– Displays field properties for selected field

• Rules when naming fields and database objects– Up to 64 characters and any combination of:

• Letters• Numbers• Spaces• Special characters except ., !, `, [, and ]

Page 13: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Working in Design View (cont’d.)

• Rules when naming fields and database objects (cont’d.)– Cannot begin with space

• Some organizations establish standards for naming objects and fields

• Field size property – Limit number of characters to store in Short Text field – Set the type of numeric data in Number field– Create a reasonable margin of error

13

Page 14: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Adding Descriptions to Fields in Table Design View

• Description property – Document contents – Identify field as primary or foreign key – Provide users with instructions about entering

values into field• Primary Key button– Access adds a key symbol to indicate the table’s

primary key

14

Page 15: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating a Table in Design View

• Click Table Design button on Create tab• Enter field names, data types, and properties

15

Page 16: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Evaluating and Testing the Table Design

• By moving to next record – Access saves record in table– To cancel record • Press Esc key

• After designing table– Evaluate for potential problems

16

Page 17: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Displaying Descriptive Field Names Using the Caption Property

• Caption property – Changes way field name is displayed– Specifies how field name will appear in different

database objects– Default caption property • Field name for all data types

17

Page 18: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Formatting Field Values Using an Input Mask

• Input mask – Predefined format – Applied to field – Values are displayed using format specified– Ensures that all of necessary data entered

• Literal characters– Not stored in database– User does not need to type them

• Use the Input Mask Wizard18

Page 19: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Input Mask Characters and Descriptions

19

Page 20: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 20

Validating Fields to Ensure Accurate and Consistent Data

• Validation rule – Compares data entered by user against one or

more valid values• Validation Rule property – Specifies valid values that users can enter

• Validation Text property– Opens a dialog box that explains the valid values

Page 21: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Validating Fields to Ensure Accurate and Consistent Data (cont’d.)

21

Page 22: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Automating Data Entry by Using a Default Field Value

• Default Value property – Enters default value into any type of field – Except for AutoNumber field

22

Page 23: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Automating Data Entry by Using a Lookup Field

• Lookup field– Lets user select field value – From: • List of existing field values stored in database • List of values specified when lookup field

created• Change field’s data type to Lookup

23

Page 24: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Level 1 Summary

• Create tables by:– Entering data– Using design view

• Customizing tables– Captions– Validation rules– Using Lookup

24

Page 25: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Level 2 Objectives:Populating and Relating the Database Tables

• Create additional tables for the database• Import data into a database• Work with primary and foreign keys• Create one-to-many and many-to-many

relationships between tables• Use a subdatasheet to view related records

25

Page 26: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 26

Populating the Database Tables

• Populating database– Load tables with data– Enter data in Datasheet view– Import data• Copy and Paste• Import from Excel workbook

Page 27: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Importing and Copying Records from One Table to Another

• Import existing data from another Access table– Table structure must be identical– Open tables in Datasheet view– Select all of records– Click Copy button– Open target database table– Click Paste button

27

Page 28: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Importing Data from an Excel Workbook

• Can import data and create table at same time– Review contents of workbook to understand how

it is arranged• If column heading names comply with rules

for naming fields in Access: – Access uses them as field names data imported

• If column headings are absent/do not comply:– Access assigns generic field names

28

Page 29: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Importing Data from an Excel Workbook (cont’d.)

• Access can import most data from worksheet– But not graphics– Formulas converted to numbers– Hyperlinks imported as text data

• Usually, the entire worksheet is imported– Can import named ranges of data

29

Page 30: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 30

Page 31: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Setting a Primary Key Field

31

Page 32: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 32

Working with Primary and Foreign Keys

• Primary key and foreign key counterparts – Must have same data type, field size, and field values

• Primary key value – Must exist before entering corresponding record if

referential integrity is set– Cannot be null

• Required property– Nonprimary key field– Ensures that users enter value into field

Page 33: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Working with Primary and Foreign Keys (cont’d.)

• Works to make data retrieval faster– Access creates index for primary key field

• Index– List maintained by database– Associates field values in indexed field with

records that contain field values

33

Page 34: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating an Index

• Increase speed at which access searches• Open table in design view– Select field to index– Click indexed property list arrow

• Create index for any field– Except fields of type• Calculated• Attachment• OLE object

34

Page 35: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 35

Page 36: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating an Index (cont’d.)

• View indexes created in table– Click indexes button on Show/Hide group on Design

tab• Create indexes for as many fields as necessary to

optimize searches in database– Records indexed when table saved– Updated automatically as records added, deleted, or

changed – As database grows

• Indexes might slow down database

36

Page 37: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating an Index (cont’d.)

• Increases size of database • Slows down database – Must update index as users add, change, and delete

records• Add indexes as needed – When improved query performance is necessary

• Delete indexes to:– Increase speed – Reduce file size

37

Page 38: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Creating One-to-Many Relationships Between Tables

• Open relationships window– Click relationships button on Database Tools tab

• Relationship has certain properties – Type• One-to-many• One-to-one• Many-to-many

– Attributes • Specify how to manage changes when records

updated or deleted

38

Page 39: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 39

Page 40: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Edit Relationships Dialog Box

40

Page 41: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 41

Creating a Many-To-Many Relationship Between Tables

• In Design view– A junction table to create the many-to-many

relationship– The primary key is a combination of fields• Referred to as a composite primary key

– Create the one-to-many relationship between individual tables involved

– Create the many-to-many relationship

Page 42: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Using a Subdatasheet to View Related Records

• After importing data into database– Open each table in Datasheet view – Check data for problems

• Expand indicator (box with the plus sign) appears for relationships– Click to view subdatasheet with the related

records

42

Page 43: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Level 2 Summary

• Import data from – Other Access tables– Excel

• Index– Used to aid searches

• Create relationships using Relationships Window

43

Page 44: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 44

Level 3 Objectives:Maintaining and Securing a Database

• Learn about the role of the database administrator

• Compact repair and back up a database• Document the database design using the

Database Documenter• Secure a database from unauthorized use

Page 45: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 45

The Database Administrator Role

• Database administration (DBA)– Responsible for maintaining database– Sets security and other features of database

• Default option for opening database– Available to other users at same time

• Open access database in four ways– Open mode, Open Read-Only mode, Open

Exclusive mode, Open Exclusive Read-Only mode

Page 46: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Compacting and Repairing a Database

• Compact– Data and objects reorganized– Unused spaces reassigned and deleted– Result• Decreased file size • Improved efficiency

– Can be done manually or every time database closed• Backing up the database before compacting and

repairing is good procedure

46

Page 47: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 47

Backing Up a Database

• Creates copy of database – Use to restore in event of loss

• Schedule database backups based on manageable amount of data loss

• Store copy in fireproof location offsite• Created on external media such as:– CD, DVD, USB flash drive, external hard drive

Page 48: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 48

Backing Up a Database (cont’d.)

• Back up database– Click File tab, Share tab, Save Database As button– Under Advanced, click Back Up Database– Opens the Save As Dialog box for location to save

backup– Use default backup database name (add date)

• Might take few minutes to several hours• Backup copy can be opened like any other

Access database

Page 49: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Documenting the Database Design

• Database Documenter – Produces report of every object or just selected

objects in database• Click Database Tools tab, and then click the

Database Documenter button– Tabs at top of documenter dialog box – Select objects by type

49

Page 50: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Documenter Dialog Box

50

Page 51: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Securing a Database From Unauthorized Use

• Plan for and to prevent data loss• Protect database from unintentional or malicious

damage• DBA must open database with exclusive access

prior to setting protection features• Tools– Setting database password– Encrypting a database– Hiding database objects

51

Page 52: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Using a Password to Protect a Database

• Password– Collection of characters that user types to gain

access to file• Database administrator sets database

password – Users cannot open database file in Access unless

they provide correct password

52

Page 53: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Encrypting a Database to Prevent Unauthorized Use

• Access 2013 combines two tools for database security– Encryption and database passwords– When you encrypt a database with a password,

the data is made unreadable by other tools• Encrypt with Password option

53

Page 54: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013

Hiding Database Objects From Users

• Casual users may damage database by:– Unintentionally altering object’s design – Deleting object entirely

• Hide objects from being displayed in Navigation Pane– User will not be able to accidentally or intentionally

damage database• Revealing hidden object not difficult• Hide using Properties dialog box

54

Page 55: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 55

Level 3 Summary

• Compact database• Backup database• Document database• Secure database– Password– Encryption– Hiding objects

Page 56: Ch02 cmpt110

Succeeding in Business with Microsoft Access 2013 56

Chapter Summary

• Create tables using one of three methods• Import data from other Access tables or Excel• Create relationships using Relationships

Window• Secure database– Password– Encryption– Hiding Objects