Beruflich Dokumente
Kultur Dokumente
Completed by
Firas M. Kadhum Iraq - Baghdad
An Overview of MS-Access
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
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
Access window
objects bar
Database window
groups bar
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
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.
15
Table1 City
16
17
7. Click the Save button and then click the Datasheet View button.
The table appears in Datasheet view
18
19
Format
Input Mask
Decimal Places
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
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
Description
Manual form creation (maximum control) Automated form creation assistant Automatically creates form without user intervention
37
38
1.
2.
Field selection
3.
39
Form layout
4.
Style
5.
40
5.
6.
41
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
44
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