access introduction

40
Database Management System MS Access

Upload: jithin-clashes-zcs

Post on 27-Jan-2015

114 views

Category:

Business


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Access introduction

Database Management SystemMS Access

Page 2: Access introduction

What Is a Database?

• Collection of data organized in such a way that data can be searched, modified, added, removed efficiently

• Database System: database in digitized form

• Database Management System (DBMS)—software system to manipulate database—add, remove, modify, search

Page 3: Access introduction

Relational Database

• All data items are organized by tables.– E.g., in School DB, tables for

• Students (firstName, lastName, phone, email)

• Faculties (firstName, lastName, phone, officeNo.)

• Courses (department, crsNumber, title, credits)

• Classes (time, location, course, classNum)

• Schedule (student, class)

• Buildings(bldgName, hasElevator, hasADA)

• Rooms (roomNo, building, capacity, hasInternet)

Page 4: Access introduction

Students Table

firstName lastName phone email

Anne Anderson 123-4568 [email protected]

Ben Benson 234-5678 [email protected]

Cathy Carson 345-6789 [email protected]

Dan Danson 456-7890 [email protected]

Erin Emmerson 567-8901 [email protected]

Frank Farrington 678-9012 [email protected]

Page 5: Access introduction

Linking Tables

Students

Schedules

Classes Courses

Faculty

Rooms Buildings

Page 6: Access introduction

MS Access

• Organized into Objects– Table

• Contains data—most important

– Form• For easier input of data

– Report• For formatted printout

– Query• For asking particular info from multiple tables

Page 7: Access introduction

Introduction to MS Access (1.1)

• Objectives– To Open existing database– To add a record

Page 8: Access introduction

• 1. Use Windows Explorer to copy Bookstore.mdb from g to a drive.

• 2. Open a DB (Bookstore.mdb in a drive) & Add a record

• 3. Open a table– move from record to record– move from field to field (Tab)

Page 9: Access introduction

Adding New Records

• 5. Add a New Record– Record 1

• 0-13-754243-7

• Exploring Microsoft Office 97 Volume I, Grauer/Barber 1997

• $45, Prentice Hall

• 6. Add a Second Record– Record 2

• 0-13-271693--3

• Exploring the Inter/2nd Ed

• $28.95, Prentice Hall

Page 10: Access introduction

• 8. Print the Table– FilePage SetupPage tabLandscape

option. Click OK.– FilePrintAll option. OK.

• 9. Exit Access– Close the Table– Close the Database– Close Access

Page 11: Access introduction

Manipulating Records and Fields

• Replacing fields

• Sorting records

Page 12: Access introduction

Maintaining the Database (1.2)

• Add, edit, delete record

• Examine Form

• Examine a Report

• Print a Report

Page 13: Access introduction

• 1. Retrieve Bookstore db.• 2. Double-click Books table.

– Click in Title field– EditFind– Enter Exploring Windows 95 in the Fid What text box.– Click the Find Next button.– Change it’s price to $28.95.

• 3. Edit->Undo Current Field/Record• 4. Delete Command

– Click a Guide to SQL.– Delete the record. (Deletion is not Undo-able.)

Page 14: Access introduction

• 5. Data Validation– New Record.– Enter the following:

• 0-07-041127-1, Getting Ahead by Getting Certified, Martinez, 1998, xxxx. (39.90), McGraw Hill.

• 6. Open the Books Form– Forms buttonBooks form. Maximize

• Add Record button. Add the following• 1-56604-229-1, HTML Publishing on the Internet, Budnick,

Mendana PressThe Replace Command

• 7. Replace Command– ViewDatasheet View– Ctrl+Home.– EditReplace.

• Find What: Prentice-Hall• Replace with: Prentice Hall• Look in: Publisher

Page 15: Access introduction

• 8. Print a Report– Reports buttonPublisher report

• Type Pretice Hall in the parameter dialog box.

– Zoom boxFit– Print Preview– Print

Page 16: Access introduction

Changing Field Properties

• Field size (Text)

• Caption

• Required

Page 17: Access introduction

Creating a Table (2.1)

• A particular table should contain all information on a particular subject.– Book, student, employee, customers, catalog

product, warehouse inventory, automobile inventory, bibliography, investment portfolio, etc.

• What type of information do you want to maintain in a table?

Page 18: Access introduction

Two-Step Process

• To create a Student table– 1. Define a table structure (in Design View)

• SSN Text• FirstName Text• Address Text• City Text• State Text• Postal Code Text• Phone Text• BirthDate Date• FinancialAid Logical (Yes/No)• Credits Number

– 2. Input data items (in Datasheet View)

Page 19: Access introduction

Using Table Wizard to Create Table

• 1. Create a a New Database– Run Access. Click option button Blank Access

Database.– In the Save In text box, select drive a:

Go to folder Exploring Access.Save new file as My First Database.

– Click the Create button.

Page 20: Access introduction

• 2. Create the Table– In the database window (My First Database), click the

Tables button.– Click the New button (at the top). Select Table Wizard.

Click OK.

• 3. The Table Wizard– In the Table Wizard, click Business option button. In

the Sample Tables list box, select Students (near the bottom).

– Transfer StudentID, FirstName, LastName, Address, City, & StateOrProvince.

– Rename StateOrProvince to State.– Add PostalCode and PhoneNumber.

Page 21: Access introduction

• 4. The Table Wizard (continued)– Accept Students as the Name of the Table– Accept Yes, set a primary key for me.– Click Next.– Click Modify the table design.– Click Finish.– FileSave

• 5. Add Additional Fields– In the design view, enter BirthDate as a new field.– Change Data type to Date/Time.– Add Gender as Text field.– Add Credits as Number field.– Add QualityPoints as Number field. (NB. No space in

field name)

Page 22: Access introduction

• 6. Change the Primary Key– Point to first field. Right-clickInsert Rows.– Enter SSN for field name.– In the Properties area, select Yes for Required box.– Click SSN field, click Primary Key button.– Click StudentID field. Right-clickDelete Rows.

• 7. Add an Input Mask– Click in SSN. Click the Input Mask box in the

Properties area.– Click the Build button (at right)– Select Social Security Number.– Try it by type 123456789.– Select BirthDate, show Input Mask, and choose Short

Date format. Say Yes to Save.

Page 23: Access introduction

• 8. Change the Field Properties– Click FirstName.

• In the Properties area, change size to 25.• In the Required box, choose Yes.

– Click the State field.• Change size to 2• In the Format box, type >

– Click the Credits field• Change Field Size to Integer.• In the Default Value box, delete 0.

– Click the QualityPoints• Change Field Size to Integer.• Delete 0 from the Default Value.• Save the table.

Page 24: Access introduction

• 9. Add a Validation Rule– Click Gender field.

• Change size to 1.• In the Format box, type >.• Click the Validation Rule box. Type “M” or “F”. (This means that

only M or F will be acceptable.)• In the Validation Text box, type “You must specify M or F.”• Save.

• 10. Datasheet View– Click the View button.– Type 111111111 for SSN in the first record.– Enter, to move to FirstName field. Enter Ronnie Adili.– Enter the following (P AC-64)

• 111-11-111 Ronnie, Adili, 3543 Queen Avenue, Minneapolis, MN 55476-9899 (612)445-7654

• 22222222 Christoper Gibson, 9807 S.W. 152 Street, Miami, FL 33157-232, (305)235-4563

Page 25: Access introduction

• 333333333, Nicholas, Korba, 85 Bayshore Drive, San Francisco, CA, 94114-5533, (415)664-0900

• 11. Enter Additional data– Enter two more records, deliberately making

mistakes in Credits, S in Gender.

• 12. Print the Table– FilePrint– Close

Page 26: Access introduction

Two-Step Process (2)

• To create an Employee table– Define a table structure (in Design View)

• EmployeeID Text• FirstName Text• Address Text• City Text• State Text• Postal Code Text• WorkPhone Text• DateHired Date• Married Logical (Yes/No)• Deductions Number

– Input data items (in Datasheet View)

Page 27: Access introduction

Adding Fields

• Click Design View button.

• Insert new row after HomePhone.

• Add WorkPhone (Text)

Page 28: Access introduction

Adding (and Changing) the Primary Key

• Primary key makes each record unique in a table.

• Try to choose a field that is naturally unique for each record.

– SSN for Employee record

– ISBN for Book record

– Call number of a library book

– Sales number

• or, create a field of unique numbers (AutoNumber)

Page 29: Access introduction

Adding an Input Mask

• To format certain data items automatically– SSN– telephone number– ZIP– Date– Time

Page 30: Access introduction

Report Wizard (3.1)

• 1. Open the Our Students Database– Click Reports buttonNewReport Wizard

• 2. ReportWizard– Click LastName, FirstName, PhoneNumber, & Major

• 3. Report Wizard (cont)– Sort by LastName– Tabular layout– Portraait orientation– Adjust field width so all fields fit on a page. Next– Corporate. Next– Title: Student Master List– Finish

Page 31: Access introduction

• 4. Preview the Report– Preview at 75%. Close

• 5. Modify an Existing Control– Click the border on containng the Now function from the footer to

the header.– Align right (with button on toolbar)– Right-clickPropertiesFormat tabFormat propertyShort Date– Save

• 6. Add an unbound control– Crate label in footer. – Type: Prepared by your name.– Right-click-PropertiesFont SizeFont Size9

Page 32: Access introduction

• 7. Change the Sort Order– ViewSortingand Grouping.– In Field Expression box, click Major– On the next line, click LastName– View

• 8. View the Modifed Report– Print Preview– Save. Print

• 9. Report Properties– Click Report button on the database window.– Select Student Master List.– Right-clickPropertiesDescription text box– Type: This report lists every student in alphabetical

order by name within major. It also contains the student’s telephone number.

– OK

Page 33: Access introduction

Creating a Query

• Query • lets user to ask questions

• allows user to choose a subset of table that satisfy certain conditions

• Given Students table• How many are from California?

• Who are majoring in Business?

• Who are from California AND majoring in Business?

Page 34: Access introduction

USA Table

• The fields in the USA table are:– Name– Capital– Nickname– Year established– Population– Area– Region (Pacific, Mountain, New England, South

Central, North Central, Middle Atlantic

Page 35: Access introduction

Queries

• States in the Pacific region

• States in the Pacific OR New England region

• States with a population over 5,000,000

• States established since 1900

• States established before 1900 AND having a population over 5,000,000

• States established in the 1800’s

• States established in the 1700’s

Page 36: Access introduction

Queries on Students

• List all Business Majors• List Business Majors from Florida• List Communications Majors Receiving Financial Aid• All Students from Florida• Engineering Majors with Fewer than 60 Credits• Students with 60 to 90 Credits• Engineering Majors with Fewer than 60 Credits or

Communicaitons Majors Born on or after April 1, 1974

Page 37: Access introduction

Creating a Select Query (3.2)

• 1. Open Our Students database– QueriesNew– Design View is open

• 2. Add the Students Table– Select Students tableAddClose. Maximize. Expand the

upper portion.

• 3. Create a query– Drag LstName field from Students table to the first column.– Drag FirstName, PHoneNUmber, Major, and Credits to the

QBE grid.– Adding & Deleting fields

Page 38: Access introduction

• 4. Specify the Criteria– To display all UNDECIDED majors:

• In Criteria row for Major, type Undecided• In Sort under LastName field, select Ascending• Save• Type Undecided Major as the Query name. Click OK.

• 5. Run the Query– QueryRun (Run button)

• 6. Modify the Query– To display all UNDECIDED majors with more than 30 credits– Uncheck Show check box in the Major field– In Criteria row under credits, type >30.– Save.– Run

Page 39: Access introduction

• 7. Create a Report– Open Our Students Database– Click Reports buttonCreate report by using Wizard– Tables/Queries list boxQuery: Undecided Major– Click >> button. Next.– Next, Next– Tabular layout, Portrait orientation, Soft Gray.– Title: Undecided Major. Finish

• 8. View the Report– Place date in the header.– Place your name in the footer.

Page 40: Access introduction

Other Queries

• All students from California or Florida

• All Business students from Florida

• All Education students from California or Florida

• All Education students with credits over 30

• All Education students with credits between 30 and 60