44
CHAPTER 1 – INTRODUCTION TO ACCESS Akhila Kondai [email protected] October 07, 2013

CHAPTER 1 – INTRODUCTION TO ACCESS

  • Upload
    ronia

  • View
    25

  • Download
    0

Embed Size (px)

DESCRIPTION

CHAPTER 1 – INTRODUCTION TO ACCESS. Akhila Kondai [email protected] October 07, 2013. Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: CHAPTER 1  –  INTRODUCTION TO ACCESS

CHAPTER 1 – INTRODUCTION TO ACCESS

Akhila [email protected] 07, 2013

Page 2: CHAPTER 1  –  INTRODUCTION TO ACCESS

INTRODUCTION• A database consists of one or more tables to store

data, one or more forms to enter data into the tables, and one or more reports to output the table data as organized information.

• The Navigation Pane organizes and lists the database objects in Access database.

• The Datasheet view is where you add, edit, and delete the records of a table.

• The Design view is where you create tables, add and delete fields, and modify field properties.

Page 3: CHAPTER 1  –  INTRODUCTION TO ACCESS

INTRODUCTION• A Primary Key is the field that uniquely identifies

each record in a table.• A Form is an object that enables you to enter,

modify, or delete table data.• A Query is a question that you ask about the data

in the tables of your database.• A Criterion is a number, a text phase, or an

expression used to filter the records in a table.• A Report contains professional looking formatted

information from tables or queries.

Page 4: CHAPTER 1  –  INTRODUCTION TO ACCESS

OPENING A TABLE

• Download the file Bookstore.accdb• In the Tables areas of the Objects Bar, • Double-click Books• Notice a table with 22 records showing in

Datasheet view

Page 5: CHAPTER 1  –  INTRODUCTION TO ACCESS

LOOKING IN DATASHEET VIEW

• Datasheet view shows a table’s contents in rows and columns like a spreadsheet would

• Each Field Name is inside a clickable “Field Selector” that will highlight that column

• Each row has a clickable “Record Selector” to its left…

Page 6: CHAPTER 1  –  INTRODUCTION TO ACCESS

TABLE IN DATASHEET VIEWField Names & Selectors

Records

Navigation

Page 7: CHAPTER 1  –  INTRODUCTION TO ACCESS

NAVIGATING A DATASHEET

• The current record is shown with an amber highlight

• Navigation buttons at the bottom of the table window allow for moving around the table easily…

Page 8: CHAPTER 1  –  INTRODUCTION TO ACCESS

NAVIGATION BAR

Page 9: CHAPTER 1  –  INTRODUCTION TO ACCESS

ADDING RECORDS

• Click the “New Record” button at the bottom

• Enter 5-555555-55-5 for the ISBN Number• Enter “Access is Your Friend” for a title• Enter your last name as an Author…• Put 2010 for the year• Make the book 95.00• Make the publisher: Que Publishing

Page 10: CHAPTER 1  –  INTRODUCTION TO ACCESS

EDITING A RECORD

• Let’s say that a price changed on the “Presentation Design Book”

• Change the price from $31.95 to $42.95

Page 11: CHAPTER 1  –  INTRODUCTION TO ACCESS

DELETING A RECORD

• Delete Cobol book from Prentice Hall .• Right click the record selector and then

select Delete Record.• Confirm the “Permanent” deletion.• Close the table clicking its “X”…

Page 12: CHAPTER 1  –  INTRODUCTION TO ACCESS

MANAGING FIELDS OF BOOKS TABLE

• View -> Design view

• Click on last empty cell of FIELD NAME and give one field name and its appropriate DATA TYPE.

• Note: You can observe the Field properties at bottom

• Switch to DATA SHEET view and observe the new Field added to the records.

Page 13: CHAPTER 1  –  INTRODUCTION TO ACCESS

FORMS

Form – Object one uses to add, maintain, & view records in a database

• Gives a different view to do this in than from Datasheet View

• Easier to use for less knowledgeable people…

Page 14: CHAPTER 1  –  INTRODUCTION TO ACCESS

USING A EXISTING FORM

Forms make it easy for anyone to work with information in a table in a simple interface…

• Under “Forms” in the object bar, • Double click Books• Click the last record button to see your

entry !

Page 15: CHAPTER 1  –  INTRODUCTION TO ACCESS

ADDING/DELETING/FINDING RECORDS WITH FORMS

• Use the controls to return to the first record

• Note there being 22 records• Create a new record ( ISBN ‘6-666666-66-

6, Year 2010 and give other details also)• Find the record with ISBN Number ‘0-07-

070318-3’ • Delete this record

Page 16: CHAPTER 1  –  INTRODUCTION TO ACCESS

USING AN EXISTING REPORT

Report – Nicely formatted display of information suitable for printout

• Close the form only• In Reports object bar area Double click All

Books• Find your two entries under the appropriate

publishers

Page 17: CHAPTER 1  –  INTRODUCTION TO ACCESS

QUERIES

• The idea is to save the time of having to manually look through a myriad of records to try and find the information needed

• Let’s take a look at an existing query…

Page 18: CHAPTER 1  –  INTRODUCTION TO ACCESS

QUERIES

• A Query is a question one asks about the data stored in a database

• Access responds by displaying specific records that answer the question

• In creating a query, we tell access which fields are needed and what criteria needs to be met

Page 19: CHAPTER 1  –  INTRODUCTION TO ACCESS

AN EXISTING QUERY

• Close the report• In the Queries area of the objects bar, • Double-click Publication Year• Enter 2010 and click OK• You should see your two records.

Page 20: CHAPTER 1  –  INTRODUCTION TO ACCESS

COMPACT AND REPAIR

• Reduces the size of the database• Perform this after you done working with

access database.• File->info->Compact and repair database

Page 21: CHAPTER 1  –  INTRODUCTION TO ACCESS

GET THE SECOND DATABASE

• Close the Bookstore database• Download and open the file

Look_ahead.accdb

* Premise: We are running a company and this database tracks information on our employees

Page 22: CHAPTER 1  –  INTRODUCTION TO ACCESS

FILTERS

• Give a temporary view of desired data to help isolate portions

• Filter by Selection – lets us specify an example

• Filter by Form – more powerful, can search for records meeting multiple conditions and by operators such as: <, >, <=, >=

Page 23: CHAPTER 1  –  INTRODUCTION TO ACCESS

FILTER BY SELECTION EXAMPLE

Say we wish to isolate our employees with poor performance…

• Open the Employees table• Click in one of the field values containing

Poor• Click Selection in the Sort & Filter group• Select Equals Poor• Click Toggle Filter to turn off

Page 24: CHAPTER 1  –  INTRODUCTION TO ACCESS

FILTER BY FORM EXAMPLESay we want to see all Females making over $40k…• Select Advanced in Sort & Filter group• Choose Filter By Form• Remove Poor from performance• Select F for Gender• Enter >40000 for Salary• Click the Toggle Filter button• Review the results• Toggle the filter off

Page 25: CHAPTER 1  –  INTRODUCTION TO ACCESS

SORTING ON A SINGLE FIELD

Sorting allows us to arrange the way the table data looks…

• Click in a record under the Last Name field• Click the Sort Ascending button• Next, sort ascending on Salary

Page 26: CHAPTER 1  –  INTRODUCTION TO ACCESS

SORTING ON MULTIPLE FIELDS

• Fields must be side by side to do this• Click and Drag to highlight both the

LastName and FirstName fields• Sort Descending (Note the Smith’s first

names)• Do it again Ascending

Page 27: CHAPTER 1  –  INTRODUCTION TO ACCESS

DATABASES & RELATIONSHIPS

• A Database is a collection of “Related” tables– This can also be called a “Relational

Database”• A Common Field between tables is what

allows a relationship to exist. This works by way of “Primary” and “Foreign” keys…

Page 28: CHAPTER 1  –  INTRODUCTION TO ACCESS

PRIMARY KEYS

• Primary Key – Field in a every table whose field values are unique for every record

• Examples might be things like:– Student ID numbers– SSN number– Cell Number– Anything that will not have duplicates as

additional records are entered

Page 29: CHAPTER 1  –  INTRODUCTION TO ACCESS

RELATIONSHIPS

• Foreign Key – Similar/Same field in the second related table in the relationship– Primary key field in relationship will have similar

data type and content to foreign key field– The two tables are joined together on the

primary and foreign keys and form a Common Field.

Page 30: CHAPTER 1  –  INTRODUCTION TO ACCESS

RELATIONSHIPS

• The link formed through this Common Field which is dubbed in one case as a “primary key”, and in another as a “foreign key”, allows tables to share data

• Note that the “Look Ahead” database has 3 tables, but we will only look at 2 of them..

Page 31: CHAPTER 1  –  INTRODUCTION TO ACCESS

1: EMPLOYEES TABLE…

EmployeeID is the Primary Key as all numbers are unique for employee records

Page 32: CHAPTER 1  –  INTRODUCTION TO ACCESS

2: LOCATIONS TABLE…

LocationID is the primary key and each record has a unique LocationID designator.

This will tie back to the Employees table.

Page 33: CHAPTER 1  –  INTRODUCTION TO ACCESS

RELATIONSHIPS

• Databases are all about efficiency and not having to store the same information more than once if multiple records need it

• Types of Relationship:– One to One– One to Many– Many to Many

Page 34: CHAPTER 1  –  INTRODUCTION TO ACCESS

RELATIONSHIPS• In this example, we know that multiple people

work at the same office address. One address can have many related Employees (One to Many)…

• Instead of typing the same address in each record for every Atlanta office employee: “450 Peachtree Road…”

• We can assign a simple relationship to a “Locations” table and reference this information to a given location with a short common code of “L01” between the tables…

Page 35: CHAPTER 1  –  INTRODUCTION TO ACCESS

ONE TO MANY RELATIONSHIP

Typing “L01” when entering an employee and having it equate to the entire address saves MANY characters in databases as it is reused over and over.

“L01” is 3 characters and the entire address is over 30 !

(One instance here)(Many here)

Page 36: CHAPTER 1  –  INTRODUCTION TO ACCESS

MAKING THE RELATIONSHIP

These tables need to be tied together (related) to work this way…

Open the Relationships WindowDatabase Tools ribbon > Relationships

Click Show TableDouble click Employees & Locations, then

Close

Page 37: CHAPTER 1  –  INTRODUCTION TO ACCESS

THE RELATIONSHIPS WINDOW

• The Relationship window depicts included table structures and their associations

• Within the structures, we see each table’s fields

• Primary keys are shown with a key icon

Page 38: CHAPTER 1  –  INTRODUCTION TO ACCESS

MAKING THE RELATIONSHIPS

Drag “LocationID” from the “Locations” table to “LocationID” in the “Employees” table.

Notice the “One-To-Many” referenceClick to Enforce Referential IntegrityClick Create…

Page 39: CHAPTER 1  –  INTRODUCTION TO ACCESS

RELATIONSHIP FORMED• Note the One to Many

(1 to infinity symbol) that formed on the join line…

Close and save the relationship

Run the “Employee Information” query to see data pulled together from both tables…Note, the relationship we made was already created in the query we ran and we

did this only for increased understanding of how to create relationships.

(Relationship Primary Key)

(Relationship

Foreign Key)

Page 40: CHAPTER 1  –  INTRODUCTION TO ACCESS

QUERY RESULTS

Information is pulled from the “Employee” and “Locations” tables through their relationship and shown united within the query results to give us a complete picture of the information !

The LocationID field was used behind the scenes to pull it all together with the L01 value

The full address is actually only stored (taking up space) once in the database, and we are able it multiple times as needed.

Page 41: CHAPTER 1  –  INTRODUCTION TO ACCESS

41

REFERENTIAL INTEGRITY • Enforce reference integrity : You cannot enter a

foreign key value in a related table unless the primary key value exists in the primary table. And you cannot delete a primary key value if there is a foreign key referencing that primary key.

• Example : Here you cannot enter location information into Employees table unless the location information is first entered into the Locations table. Also you cannot delete records from Locations table if there are any related records for that location in the Employees table

Page 42: CHAPTER 1  –  INTRODUCTION TO ACCESS

42

REFERENTIAL INTEGRITY

• Cascade Update / Delete Related Records

Page 43: CHAPTER 1  –  INTRODUCTION TO ACCESS

HOW TO DELETE RELATIONSHIP BETWEEN FIELDS?

• Click on the line between the fields (which shows relation) and press delete key.

Page 44: CHAPTER 1  –  INTRODUCTION TO ACCESS

Questions ?