Sie sind auf Seite 1von 46

Microsoft Access

Completed by
Firas M. Kadhum Iraq - Baghdad

An Overview of MS-Access

What is Microsoft Access?


Microsoft Access is a relational database management system (DBMS or RDBMS). At the very core, it is a software engine that provides an interface between physical data and user application queries. Other examples of DBMS applications include: Oracle MySQL SQL Server DB2 Informix

Why choose MS-Access over other DBMS systems?


Cheap and easy to use (relative to other systems Oracle may require one FTE (Full-Time Equivalence ) to maintain the server as a database administrator and another FTE to serve as an application developer).

Why choose other DBMS systems over MS-Access?


- MS-Access can handle a large number of records, but is somewhat slow compared to some of the high-end platforms. - Multiple users may use the database at same time, but MS- Access is known to become unstable with greater than 3-5 users.
4

First of all you need to understand how MS Access breaks down a database. Some keywords involved in this process are: Database File, Table, Record, Field, Data-type .
Database File: This is your main file that encompasses the entire database and that is saved to your hard-drive or floppy disk. (Example: class.mdb ) Table: A table is a collection of data about a specific topic.. Field: A single characteristic or attribute of a person, place, object, event, or idea. Fields are the different categories within a Table. Tables usually contain multiple fields. Datatypes: are the properties of each field. A field only has 1 datatype. (text, number, etc)
5

When Open MS Access ?


When MS Access is launched you will see the Access window, The Access window contains a menu bar, a toolbar, a status bar and a task pane on the right side of the window. Use this task pane to create a new database or to open an existing database.
To create a new database, make a selection from the New section of the task pane. To open an existing database, select from the list of Recently opened databases or from the More files option. ( or Access Open button)

Database window :
When a database is opened, the Database window will be displayed. The Database window is the main control center for working with an Access database. The Database window contains a menu bar, an objects bar, and a groups bar. The Objects bar lists all the objects available in the database . The list of objects consists of Tables ,Queries, Forms , Reports ,Macros , Modules and Pages. You can click on any of the objects in the Objects bar to obtain a list of objects of that type.
8

Main Access data objects

Access window

objects bar

Database window

groups bar

Main Access data objects :


Tables :
What is table ? Basic container for data, arranged as a grid of rows and columns (i.e. stores all data) . Each row contains a single record. Each column represents a field within the record. Access tables: Fundamental data objects in Access , Forms, queries and reports are all based on tables. Table Wizard provides automated table creation. Tables can also be created manually for more precise specification.

10

Creating Table:
- You should select the appropriate data type for all fields so that Access will only accept the correct data type in the table. This helps prevent errors when you enter data into the fields. -For example , the DateOfBirth field should be set as a Date/Time data type so that it only accepts date entries. MS Access defines and accepts the following data types.

11

4. Create the fields as show below Click Data Type and choose from the drop-down list.
For

each field in Table , specify the following items : Field Name : Descriptive name of field to be used in table 64-character maximum Not allows here to write : period(.), accent grave(), square brackets([]), exclamation point(!) Data Type : Drop-down list displays available data types Text , Number, Date/Time, Currency, Auto number, Yes/No, OLE Object, Hyperlink, Lookup Wizard Description : Comment describing details of field. Appears on the status bar in Datasheet view when you click a row in the field's column Field properties : When you create a field for your database table you need to set several field properties 12

Hints : A relational database is a collection of tables that are related to one another based on a common field. A field, or a collection of fields, is designated as the primary key. The primary key uniquely identifies a record in the table. When the primary key of one table is represented in a second table to form a relationship, it is called a foreign key.
13

14

Data Types :
Data Type
Text Memo Number Alphanumeric data Alphanumeric datasentences and paragraphs Numeric data for calculations

Usage

Size
Up to 255 characters Up to 64,000 characters 1, 2, 4, or 8 bytes

Date/Time Currency AutoNumber

Dates and times Monetary data, stored with 4 decimal places of precision Unique value generated by Access for each new record , in other word : Automatically numbers , each record when you create a new record . May not be manually update) Boolean (true/false) data Pictures, graphs, or other ActiveX objects from another Windowsbased application A link "address" to a document or file on the World Wide Web, on an intranet, on a local area network (LAN), or on your local computer , that means hyperlinks to another document or web page.

8 bytes 8 bytes 4 bytes

Yes/No OLE Object Hyperlink

1 bit Up to about 1 gigabyte Up to 2048 characters

15

Table1 City

16

17

7. Click the Save button and then click the Datasheet View button.
The table appears in Datasheet view

8. Click on City field, the list of values appears as shown below.

18

19

Common Field Properties :


Field Property Field size Purpose determines the amount of memory needed to store a data value in the field. For Text , accepts text up to 255 characters. For Numbers, defined by type of number , such as Byte , integer, etc.. Predefined formats for field data ( Determines how the data is displayed). Ex: Short date =11/25/97 Formatting mask for user data input. With this property you can specify a pattern for all data values that you want to enter into the field. Ex: Phone number input mask = (XXX)-XXX-XXX Number of decimal points for currency values or numbers.
20

Format

Input Mask

Decimal Places

Field Property Caption Default Value

Purpose Defines the label of the field in the form or the display of the column heading in Datasheet. determines default value in field. Text or value that is automatically entered in the field when a record is created. Note: Speeds up data entry. Sets a condition for the data to be entered in the field. Error message that appears when the data entered into the field does not meet the validation rule. Specifies that a value must be entered in field. Tells Access to create an index for this data field. Note: Speeds up data searches based on this field.
21

Validation Rule Validation Text Required Indexed

1.

2.

3.

22

1.

2.

3.

23

1.

2.

3.

24

1.

3.

2.

25

1.

2.

3.

26

1.

2.

3.

27

1.

2.

3.

28

1.

2.

3.

29

1.

2.

3.

Note: Try to enter a new record but leave the Last Name field empty. Will appear warning message that message inform you can not leave this field without enter a value in it.
30

Queries:
What is a Query?
A question asked of the database Used to extract specific information from database Queries are composed of structured query language (SQL) statements Example:
SELECT S.SNAME, S.STATUS, S.CITY, P.PNAME, P.COLOR, SP.QTY FROM S , P, SP WHERE S.CITY ="Pitesti" And P.CITY ="Bucharest";

-MS Access allows queries to be created graphically ( graphical tools :Query by example) Hides complexity of SQL language

31

Creating Queries:
From database window, select Queries tab, then click on New Select Design View Specify fields to show Select the fields to be displayed by clicking on the Show checkbox Specify criteria Enter the criteria expression for the desired field in the query grid In this example, we want to select all suppliers live in Pitesti city. We will set the criteria for the City column to Pitesti if multiple fields have criteria set, they must all be satisfied to select record (logical AND) Viewing SQL Use View/SQL to see a listing of the SQL statements produced by the design

32

1.

33

Query by example 2.

3.

34

4.

5.
35

6.

SQL Code

36

Form:
- What is a Form ?
Electronic version of paper form. Used to simplify entry of data into an Access database Able to display many entry fields on one screen

Creating Form:
Most commonly used form creation options

New form options


Design View Form Wizard Auto form

Description
Manual form creation (maximum control) Automated form creation assistant Automatically creates form without user intervention

37

Creating forms with Form Wizard :


Using Form Wizard
From the database window, click on the Forms tab, then click on New The New Form dialog box will be displayed Select the name of the table or query to be used to create the new form

Form creation steps


Field selection Form layout Style

38

1.

2.

Field selection

3.

39

Form layout

4.

Style

5.

40

5.

6.

41

Backup and restore a database :

You may want to create a backup of your data so that if you lose or damage your database, you can recover from the backup. You can use a backup tool, such as the Microsoft backup tool, or some other backup program such as Norton ghost etc. To restore the data from the backup, you need to use the same backup tool according to the instructions associated with that tool.

42

Compacting a database :

It is a good idea to periodically compact and repair a database to recover wasted space created by adding, deleting, and modifying records. Access has a Compact and Repair feature: Open a database Click on Tools and then Options On the Options menu, select Compact on Close. Selecting this option will cause your database to be compacted and repaired every time you close it.

43

Setting the Compact on Close option :

44

Compacting reduces database storage size :

45

Summary :

Use Access to create and work with relational databases The database window helps you work with Access objects Access objects help you find, enter, and manage information Duplicate data is minimized Data entry is faster and easier Information can be viewed and sorted in multiple ways Information is more secure ,it can be shared among several users and faster and easier to retrieve it.
46

Das könnte Ihnen auch gefallen