chapter 1 – introduction to access

Post on 17-Feb-2016

26 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

CHAPTER 1 – INTRODUCTION TO ACCESS. Akhila Kondai akhila.kondai@mail.wvu.edu October 07, 2013. Introduction. - PowerPoint PPT Presentation

TRANSCRIPT

CHAPTER 1 – INTRODUCTION TO ACCESS

Akhila Kondaiakhila.kondai@mail.wvu.eduOctober 07, 2013

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.

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.

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

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…

TABLE IN DATASHEET VIEWField Names & Selectors

Records

Navigation

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…

NAVIGATION BAR

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

EDITING A RECORD

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

• Change the price from $31.95 to $42.95

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”…

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.

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…

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 !

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

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

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…

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

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.

COMPACT AND REPAIR

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

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

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

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: <, >, <=, >=

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

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

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

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

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…

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

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.

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..

1: EMPLOYEES TABLE…

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

2: LOCATIONS TABLE…

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

This will tie back to the Employees table.

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

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…

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)

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

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

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…

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)

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.

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

42

REFERENTIAL INTEGRITY

• Cascade Update / Delete Related Records

HOW TO DELETE RELATIONSHIP BETWEEN FIELDS?

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

Questions ?

top related