33
MS Access Introduction

Chapter 5 ms access-1

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Chapter 5   ms access-1

MS Access

Introduction

Page 2: Chapter 5   ms access-1

What is DataData can exist in many forms for computer use.Data stored on computers should be digital but lots of types of data in the real world involve physical measurements of continuously varying data.These need to be converted into digital data for storage and manipulations on a computer

2

Page 3: Chapter 5   ms access-1

3

Data TypesTextAlphanumericNumbers

IntegerLong integerSingleDouble

Date/time

CurrencyAutoNumberBoolean

Yes/noTrue/False-1/0

Page 4: Chapter 5   ms access-1

4

Math Operators+ Addition

- Subtraction

* Multiplication

/ Division

\ Integer Division

^ Exponentiation

Mod Modulo (remainder) division

Page 5: Chapter 5   ms access-1

5

Relational Operators

= Equal

<> Not equal

< Less than

> Greater than

<= Less than or equal to

>= Greater than or equal to

Page 6: Chapter 5   ms access-1

6

Boolean OperatorAnd Logical And Both operands are

true

Or Logical Or Either one of the operands or both of them are true

Xor Excusive Or Only one of the operands (not both of them) are true

Not Negation Operand is not true

Page 7: Chapter 5   ms access-1

7

String and Miscellaneous Operators

& Concatenation

Like Similar to

Between …and…

Between 2 values inclusive

In (list) One from the list

Is Null True if the field is empty

Page 8: Chapter 5   ms access-1

Data Structures

8

• Data is often stored in files, which consist of records, which in turn consists of fields.•For example a Company might want to store its employee information in the following format –Reference No/ Name / Date-started / DepartmentThe structure of the Employee file would be –

Ref No Name Start-Date Department

1416 J. Smith 30/05/2003 Sales

1417 K. Shah 11/02/1999 Manager

1431 R. Marques 15/10/2001 Finance

1452 T. Rodriques 27/09/1995 Sales

1461 V. Schruitz 09/12/2005 Finance

Rec -1

Rec-2

Rec-3

Rec-4

Rec-5

Field1 Field2 Field3 Field4

EmployeeFile

Page 9: Chapter 5   ms access-1

Data types of each field for the Employee File

9

Ref No - Numeric Data (Integer)

Name - Text

Date - Date Format (dd/mm/yy)

Department - Text

Flat File Structure

Ref No

Name Date Department

101 Deepa Jain 12/01/2000 Accts

102 Sam Pai 01/09/2004 HR

103 Ekta Joshi 09/09/2002 Accts

104 Sumit Ojha 07/08/2001 Sales

Page 10: Chapter 5   ms access-1

Database

A database is a collection of information that is organized so that it can easily be accessed, managed, and updated. In one view, databases can be classified according to types of content: bibliographic, full-text, numeric, and images.In computing, databases are sometimes classified according to their organizational approach.

10

Page 11: Chapter 5   ms access-1

Why are databases used?

They promote data consistency. When data is updated on a database it is up-to-date for any application which uses the database.Data duplication is reduced.It is relatively easy to expand the database as per new requirement.Security of data is easier to monitor and maintain

11

Page 12: Chapter 5   ms access-1

12

Relational DatabaseRelational databases consists of a separate tables which are related.Each table contains a primary key field that is also available in one other table.With this it is possible to combine data from different tables to produce a report.Tables also contain Foreign keys that relate tables in the database to one another. Field name may be same or different.

Page 13: Chapter 5   ms access-1

Advantages of Relational Databases

Faster data retrievalEasier expansion of the database by adding extra or new tablesNeed to change data in only one table as all other references get updated automatically because of data integrity

13

Page 14: Chapter 5   ms access-1

Example of Relational Database

14

A garage sells cars and keeps a database of sales, customers and servicing. The Primary key is Car Number. Invoice Number and Engine Id are Foreign Keys

Car Number

Make of Car Value ($)

Date the Car was sold

Mileage at sale

A 111 BBB

VW GOLF 20500 20/01/09 18100

C 202 ART

SEAT LEON 19450 15/03/09 25509

N 015 BRM

TOYATO AYGO

12700 18/12/08 16702

N 541 KIT FIAT PUNTO 13400 04/09/08 12212

S 229 RRP

HONDA CIVIC 16600 17/11/08 21099Garage Sales Table

Page 15: Chapter 5   ms access-1

Example of Relational Database

15

Invoice Number

Car Number Customer Name Customer Details

Annual Mileage

242986 R 541 KIT J. Klaus 12, Ford Rd 15000

243001 S 229 RRP K. Chan 134, Main St 25000

243221 N 015 BRM D. Meija 56 Ligo Rd 18000

243811 A 111 BBB B. Bipan 244, St Kitt Rd 20000

244002 N 015 BRM T. Guntar 87 Pebble Drive

15000

Engine Id Car Number Service Mileage

Date of last service

Any recalls outstanding

AF123452 C 202 ART 40000 20/01/09 Yes

AST23455 R 541 KIT 32000 15/03/09 No

BB219009 A 111 BBB 38000 18/12/08 No

CD567899 N 105 BRM 30000 04/09/08 No

FFF34567 S 229 RRP 39000 17/11/08 Yes

Customer Detail Table

Service Table

Page 16: Chapter 5   ms access-1

Questions – Example - 1How many records can you see in the Garage Sales Table?How many fields are there in each record?Which field contains:Numeric Data Only

Text Data Only Date type of Data only

Marina G. Erechtchoukova 16

Page 17: Chapter 5   ms access-1

Questions – Example 2How many records are there in the Customer Detail Table?How many fields are there in the Service Table?What type of database is being used between the three tables?Which field is a Foreign Key?

Marina G. Erechtchoukova 17

Page 18: Chapter 5   ms access-1

18

Access Database ObjectsTables contain rows called records and columns called fields.Queries are requests for specific information from a database. Queries are virtual tables built on a given SQL statement

Page 19: Chapter 5   ms access-1

19

Access Database Objects (cont. …)

Forms are parts of user interface. Forms are used to enter, edit or browse data from a database

Reports present requested information and allow to create hard copies.

Page 20: Chapter 5   ms access-1

20

Create a Database in MS Access 2007 and up

Click on the round Office buttonChoose New from the drop-down menuIn Create Blank Database window specify the database nameClick Create

Page 21: Chapter 5   ms access-1

21

Create TableUsing WizardDesign View

Specify field namesData typesPropertiesDetermine a primary keySave the table

Page 22: Chapter 5   ms access-1

22

Access Tables

Design viewTable structure is created and may be edited

Datasheet view Display table content in spreadsheet-like grid, Used for entering, editing or deleting data from tables

Page 23: Chapter 5   ms access-1

23

QueriesSpecify the source of dataIf multiple tables are used, specify relationships between tablesSelect desirable fields from the table(s) and options related to the fieldsSpecify a criterion

Page 24: Chapter 5   ms access-1

24

Query CriteriaTo be selected a record must satisfy a criterionExpressions may contain the following operators:

Math OperatorsRelational operatorsBoolean OperatorsString OperatorsMiscellaneous Operators

Page 25: Chapter 5   ms access-1

25

Access FormsCreate using Form WizardCreate using Form Design view

Specify source of data will be presented by the form

TableQuery

Specify fields related to the formAdd labels, titles, graphics and so on

Page 26: Chapter 5   ms access-1

26

Form Design viewForm Header –a place for titles, graphics, additional informationForm Details section – the fields used to create a form and control elements related to the fieldsForm footer –a place for any items which will appear at the bottom of the form

Page 27: Chapter 5   ms access-1

27

Form Controls

Must be bound with fields from the source table or query

Contain data from correspondent fields, labels or other controls (like command button) or another form called subform

Page 28: Chapter 5   ms access-1

28

Viewing FormsOpen databaseClick Forms tab to display all available forms in the databaseSelect the formSelect OpenTo view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes

Page 29: Chapter 5   ms access-1

29

Creating SubformsRepresent 1:N relationshipsTo add a subform to a form

Create a form that will be a subformClick on Subform/Subreport button and then click on a form where the subform should appearSpecify the source for the subformSpecify the fields to link the form and subform

Page 30: Chapter 5   ms access-1

30

ReportsReports present table contents or query results in an easily assimilated formatReports have Design view and Print PreviewReport Design View is similar to the Form Design view

Page 31: Chapter 5   ms access-1

31

Report Design ViewPage Header contains data and graphics appearing at the top of each pageReport Header contains the data and graphics appearing at the top of the first report pageDetailed section contains data from tables or queriesPage Footer contains the data and graphics appearing at the bottom of every pageReport Footer contains the data and graphics appearing at the bottom of the last report page

Page 32: Chapter 5   ms access-1

32

Report TypesColumnar reports – a single record on a pageTabular reports – datasheets: fields from the tables are presented as columnsJustified reports combine two previous types of the reports

Page 33: Chapter 5   ms access-1

33

Creating ReportsWith a WizardDesign view:

Specify source for the reportSelect Fields from the Fields ListAdd labelsAdd formatSwitch the view to see the result.