Sei sulla pagina 1di 33

MS Access

Introduction
What is Data
Data 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
Data Types
Text
Alphanumeric Currency
Numbers AutoNumber
Integer Boolean
Long integer Yes/no
Single True/False
Double -1/0
Date/time

3
Math Operators
+ Addition
- Subtraction
* Multiplication
/ Division
\ Integer Division
^ Exponentiation
Mod Modulo (remainder) division

4
Relational Operators
= Equal
<> Not equal
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to

5
Boolean Operator
And 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

6
String and Miscellaneous
Operators
& Concatenation
Like Similar to

Between Between 2 values inclusive


…and…
In (list) One from the list
Is Null True if the field is empty

7
Data Structures
• 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 / Department
The structure of the Employee file would be –
Ref No Name Start-Date Department
Rec -1 1416 J. Smith 30/05/2003 Sales
Rec-2 1417 K. Shah 11/02/1999 Manager Employee
Rec-3 1431 R. Marques 15/10/2001 Finance File
Rec-4
1452 T. Rodriques 27/09/1995 Sales
1461 V. Schruitz 09/12/2005 Finance
Rec-5
Field1 Field2 Field3 Field4

8
Data types of each field for the
Employee File
Ref Name Date Depart Ref No - Numeric Data
No ment (Integer)
101 Deepa Jain 12/01/2000 Accts
Name - Text
102 Sam Pai 01/09/2004 HR
Date - Date Format
103 Ekta Joshi 09/09/2002 Accts (dd/mm/yy)

104 Sumit Ojha 07/08/2001 Sales


Department - Text

Flat File Structure


9
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
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
Relational Database
Relational 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.
12
Advantages of Relational
Databases
Faster data retrieval
Easier expansion of the database by
adding extra or new tables
Need to change data in only one table
as all other references get updated
automatically because of data integrity

13
Example of Relational Database
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 Make of Car Value Date the Mileage


Number ($) Car was at sale
sold
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 21099

Garage Sales Table

14
Example of Relational Database
Invoice Car Number Customer Name Customer Annual
Number Details 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

Customer Detail Table


Engine Id Car Number Service Date of last Any recalls
Mileage service 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
Service Table 15
Questions – Example - 1
How 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
Questions – Example 2
How 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
Access Database Objects
Tables 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

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

19
Create a Database in MS Access
2007 and up
Click on the round Office button
Choose New from the drop-down
menu
In Create Blank Database window
specify the database name
Click Create

20
Create Table
Using Wizard
Design View
Specify field names
Data types
Properties
Determine a primary key
Save the table

21
Access Tables

Design view
Table 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

22
Queries
Specify the source of data
If multiple tables are used, specify
relationships between tables
Select desirable fields from the table(s)
and options related to the fields
Specify a criterion

23
Query Criteria
To be selected a record must satisfy a
criterion
Expressions may contain the following
operators:
Math Operators
Relational operators
Boolean Operators
String Operators
Miscellaneous Operators

24
Access Forms
Create using Form Wizard
Create using Form Design view
Specify source of data will be presented by
the form
Table
Query
Specify fields related to the form
Add labels, titles, graphics and so on

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

26
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

27
Viewing Forms
Open database
Click Forms tab to display all available
forms in the database
Select the form
Select Open
To view data use Form Navigation
Tools. To prevent data Editing, use
Locked Property for the Text Boxes

28
Creating Subforms
Represent 1:N relationships
To add a subform to a form
Create a form that will be a subform
Click on Subform/Subreport button and
then click on a form where the subform
should appear
Specify the source for the subform
Specify the fields to link the form and
subform

29
Reports
Reports present table contents or query
results in an easily assimilated format
Reports have Design view and Print
Preview
Report Design View is similar to the
Form Design view

30
Report Design View
Page Header contains data and graphics
appearing at the top of each page
Report Header contains the data and graphics
appearing at the top of the first report page
Detailed section contains data from tables or
queries
Page Footer contains the data and graphics
appearing at the bottom of every page
Report Footer contains the data and graphics
appearing at the bottom of the last report
page
31
Report Types
Columnar reports – a single record on a
page
Tabular reports – datasheets: fields
from the tables are presented as
columns
Justified reports combine two previous
types of the reports

32
Creating Reports
With a Wizard
Design view:
Specify source for the report
Select Fields from the Fields List
Add labels
Add format
Switch the view to see the result.

33

Potrebbero piacerti anche