Access 2007 is a program that allows you to create and manage databases. Adatabase is a place where you can store information related to a specific topic. How you intend to use the information will determine whether you need an Access database or a different program to create and manage your data.
click to browse the following
The relationship type you will come across most frequently, and the one created in our bookstore scenario, is theOne to Many relationship.
====================================================================
backup table without creating another table manually.
click to browse the following
What is a Database?
Access Example: Customers and Orders Tracking
Entering Data in Access
Microsoft Access is designed to manage information. Access allows you to enter the client's name, address, and phone number- the first time they do an order.
This information is entered into an Access table designed to hold basic customer information on clients. A table is a list of related information in columns and rows. In a table, each row is called a record and each column is called afield . An Access table in Datasheet View looks similar to an Excel spreadsheet, as you can see below.
Data in an Access Customer Info Table
In addition to the table with customer information, you would probably also want a table with information about the products you sell, and a third table to hold data related to specific customer orders. These tables would all be linked together, to help you make the most out of your data.
Access is called a relational database management program, because the tables are linked, or related, as you can see in the image below.
In this example, the Customer Info and Orders tables are linked by Customer ID and Book ID.
Table Relationships Diagram in Access
Now, let's assume that you want to identify the book that was most popular in the state of North Carolina. With Access, this is possible because you can search and retrieve information from multiple tables at the same time.
The Customer Info table contains information about the states, and the Order table includes information about which books were ordered. You will need information from both tables to identify the book that was most popular in a specific state.
The Customer Info table contains information about the states, and the Order table includes information about which books were ordered. You will need information from both tables to identify the book that was most popular in a specific state.
You could look at the information in these tables separately to answer your question of which book was most popular in North Carolina. In the Customer Info table, you could see all the customers from a specific state, NC. And in the Books table, you can see all the books that you have in stock. The real power of Access comes in being able to link and extract information from multiple tables to answer specific questions.
As you can see below, the results of your specific question, or query, are displayed for you.
Search Results
Challenge!
Try to answer this questions:
- What is a database?
- What type of software program is Microsoft Office Excel?
- What type of software program is Microsoft Office Access?
- Think of at least two differences between Access and Excel.
Introduction
By now, you have set up the tables you need for your database, and created fields for those different tables. Relationships provide Access 2007 with the means to bring that information together for you when you need it. This lesson explains how to establish relationships between the tables in an Access 2007 database. You will learn how to read and manipulate the relationship map. You will also learn about Primary and Foreign Keys,relationship types, and about referential integrity.
Establishing Relationships
To establish a relationship between tables:
- Click the Relationships command in the Show/Hide group on the Database Tools tab in the Ribbon.
- When the Show Table dialog box appears:
- Select each table name and click Add for the tables you want to relate.
- When you are done, Close the Show Table dialog box.
Show Table Dialog Box - You should now see a relationship map that contains all the tables that were selected.
NOTE: Tables must be closed in order to establish relationships.
Relationships Command
Relationship Map
Moving Tables in the Relationship Map
To move a table that appears in the relationship map:
- Place your mouse over the table you want to move.
- Hold down the left mouse button, and drag the table to a new location.
- Release the mouse button to drop the table in its new place.
Understanding the Relationship Map
The relationship map lists all of the tables that were selected to relate, and all of the fields that were set up for that table previously. Notice that the first field has a key icon next to it. This is the Primary Key for the table.
Primary Keys
Primary and Foreign Keys
A Primary Key is the first field in each table of the database. You may recall that this field auto numbers by default, so that every record in the table has its own unique number to identify it. Access uses this number to quickly pull information together for you when you run queries or reports, which are covered later.
In the example above, the primary key for the Customers table is Customer ID, the primary key for the Orders table is Order ID, and the primary key for the Books table is Book ID.
A Foreign Key is a field that is the Primary Field in its own table, but that shows up in another table. If you look closely at the Orders table, the fields Customer ID and Book ID appear there, as well as in their own respective tables. These fields are the primary key in their own tables, but in the Orders table, they are considered Foreign Keys.
Foreign Keys
Relating Tables
There are a few ways to establish relationships between tables:
- Using the Edit Relationships command located on the Design tab of the Ribbon
- Using the Drag and Drop method
Both methods give you the same end result, but the Drag and Drop method is much easier and saves you several steps.
Relating Tables with the Drag and Drop Method
It is easy to relate tables from the relationship map:
- Select a field name from one table by holding down the left mouse button.
- Drag the field name from the one table to the other table in the desired relationship.
- Drop the first field name onto the field name that you want to relate by releasing the left mouse button.
- The Edit Relationships dialog box appears.
- Select the Enforce Referential Integrity option. This option is explained in detail below.
- Click Create.
Relationship Map
In the example above, we selected the Book ID field from the Books table, and dragged and dropped it on the Book ID field in the Orders table.
Edit Relationships Dialog Box
Understanding Types of Relationships
Access 2007 allows for several different types of relationships. These include:
- One to One
- One to Many
- Many to Many
The relationship type you will come across most frequently, and the one created in our bookstore scenario, is theOne to Many relationship.
One to Many
The One to Many relationship means that data for that field will show up a single time in one table, but many times in the related table.
For example, let's look at one of the book titles in our bookstore. The Book ID for that book should appear only once in the Books table, because that table lists every title that we stock. But it will probably appear many times in the Orders table, because we hope that it gets ordered by many people many times.
The symbols for the One to Many relationship look like this:
One to Many Relationships
Enforcing Referential Integrity
In the Edit Relationships dialog box, an option to Enforce Referential Integrity appears.
You should click Enforce Referential Integrity to make sure that we NEVER have an order for a book that doesn't appear in our Books table. Selecting this option tells Access to check for these things when someone is working with your data records.
Editing Existing Relationships
Access 2007 allows you to edit relationships that already exist. This can be done using the Edit Relationships command on the Ribbon. However, a much simpler way is to simply double click on the link that appears in the relationship map. Either method brings up the Edit Relationships dialog box, where you can change your settings.
Challenge!
If you haven't already done so, save the sample Ready2Read database on your own computer.
- Open the database and establish a relationship between the Books table and the Orders table using the Drag and Drop method.
- Establish a relationship between the Customers table and the Orders table using the Edit Relationships command on the Ribbon.
- Edit an established relationship by double-clicking the link.
- Explore the options and settings in the Edit Relationships dialog box.
- Move the tables around in the relationship map.
Introduction
Access 2007 databases hold the actual data records inside tables. You can add, edit, and delete records directly from these tables. This lesson will show you how to work in the tables to add new records, as well as how to edit existing records using commands like Copy and Paste and Find and Replace. It will also discuss the dangers involved in deleting records from a table and the importance of setting validation rules and other field properties and to ensure that data is valid.
Adding and Editing Data in Tables
Watch the video! (10:10min) - Tips for watching our videos.
Download the example to work along with the video.
Adding Records to Tables
When you enter records into your table, you are populating the database. In Access 2007, you can do this a few different ways.
To Add Records in the New Record Row:
- Click the record row with the asterisk that appears at the bottom of the table.
- Type the data into the appropriate fields.
- Hit Enter or the Tab key to move to the next field.
New Record Row
To Add Records with the New Record Navigation Button:
- Click the New Record button in the navigation bar. The navigation bar is located in the bottom left corner of the open object pane.
- Type the data into the appropriate fields.
- Hit Enter or the Tab key to move to the next field.
New Record Navigation Button
To Add Records with the New Record Command:
- Click the New Record command in the Records group in the Ribbon.
- Type the data into the appropriate fields.
- Hit the Enter or the Tab key to move to the next field.
New Record Command
Editing Records in Tables
Sometimes it is necessary to edit records in the database. Like with every other task in Access 2007, this can be done several different ways.
To Edit a Record Directly:
- Scroll through the records or use the Navigation Buttons in the navigation bar to find the record to edit.
- Click the cell that contains the information that must be edited. A pencil icon appears to indicate edit mode.
- Type the new information into the field.
- Click outside of the record row to apply the change.
Navigation Buttons
Edit Record Mode
To Edit a Record using Find and Replace:
- Click the Find command in the Find group on the Ribbon.
- The Find and Replace dialogue box opens.
- Tell Access what to find by typing it into the Find What: area.
- Type the replace term in the Replace With: area.
- Tell Access where to look with the Look In: drop down list. Tip--The first choice in, the drop down is the field you were last in in the table.
- Tell Access what to Match: Any part of the field, the whole field, or just the start of the field.
- Tell Access how to Search: Up finds records above the cursor, Down finds records below the cursor, and All searches all records.
- Click on one of the action options:
- Find Next will find the next instance of the word in the table.
- Replace will put the new word into the table, overwriting what is currently there.
- Use Cancel to stop the edit process.
Find Command
Find and Replace Dialog Box
CAUTION: DO NOT use Replace All , as it will overwrite every instance of the Find term in the table, which can have a serious impact on your data.
To Copy and Paste a Record:
- Select the record that you want to copy. Right click and select Copy.
- Select the new record row. Then right click and select Paste. The record information appears, with a new record ID number.
To Delete a Record:
- Select the record that you want to delete. Then, right click and select Delete Record.
- A dialog box appears, telling you the action can not be undone and asking if you are sure you want to delete the record.
Delete Record Dialog Box
There may be other records that rely on the record you are trying to delete. DO NOT delete a record without knowing how it will impact the rest of your database.
Record Numbering after Deleting Records
When you delete a record, that record number is permanently deleted from the database table. If you delete the last record from a table, and then add a new record, your new record numbers will appear to be out of sequence.
====================================================================
backup table without creating another table manually.
select * into hello from m1;
No comments:
Post a Comment