You are on page 1of 8

Microsoft Access 2000 Workshop 3

Creating Relationships

Creating Relationships
A. Opening an Existing Database
1.
2.

From the Desktop, select Microsoft Access from the Programs menu.
Open the ITClass Database.

B. Making a Duplication of a Table


1.

Right-click the Students Table and then choose Copy from the pop-up menu.

1. Right-click Students and choose


Copy from the pop-up menu.

2.

Right-click anywhere within the ITClass: Database window and then choose
Paste from the pop-up menu.

2. Right-click anywhere within the


ITClass: Database table and then
choose Paste from the pop-up menu.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

3.

Creating Relationships

In the Paste Table As dialog box, enter Personal in the Table Name text box.
5. Click the OK
button.

3. Enter Personal
here.

4. Click to select Structure


and Data if necessary.

4.
5.

Make sure that Structure and Data is selected in Paste Options.


Click the OK button.

C. Modifying the Structure of a Table


1.
2.

Click to select the Personal Table.


Click the Design View button (or right-click the Personal table and then choose
Design View from the pop-up menu).
2. Click the Design
View button.

1. Click to select the


Personal table.

3.

Click on the left of the field name Class to select the entire row.

3. Click here to select


the entire row.

4.

Press the Delete key on the keyboard.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

5.

Creating Relationships

In the Microsoft Access dialog box, click the Yes button to confirm deleting the
field Class.
5. Click the Yes button to
confirm deleting the field.

6.
7.
8.
9.

Similarly, delete the ClassNo, SAMember, and Remarks fields.


Close the Personal table and save the changes when prompted.
Using similar procedures, delete the fields Name, Birthday, Address, and Hobby
from the Students table.
Close the Students table and save the changes when prompted.

D. Creating a One-to-One Relationship


1.

Choose Relationships from the Tools menu.


1. Choose Relationships
from the Tools menu.

2.

In the Show Table dialog box, click to select the Personal table and then click the
Add button.
2. Click to add the
Personal table.

3.

Similarly, add the Students table and then click the Close button to close the Show
Table dialog box.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

4.

Creating Relationships

In the Relationships window, drag the StudentID field from the Personal table
onto the StudentID field of the Students table.

4. Drag the StudentID field


from the Personal table onto
the StudentID field of the
Students table.

5.

In the Edit Relationships dialog box, click to check all the three available options
provided.
6. Click the Create
button.

5. Click to check all


the three available
options provided.

6.

Click the Create button.

A One-to-One Relationship is created between


the Personal and Students tables.

Note: To delete the relationship between two tables, simply click to select the link
between the tables, and then choose Delete from the Edit menu.
To edit the relationship between two tables, simply double-click the link
between the tables to open the Edit Relationships dialog box.
7.

Close the Relationships window and save the changes.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

Creating Relationships

E. Creating Two More Tables


1.

With the Tables object selected, click the New button to create a new table.
1. Click the New button to
create a new table.

2.

In the New Table dialog box, choose Design View and then click the OK button.

2. Choose Design View and


then click the OK button.

3.

4.

Create three fields with the structure below.


Field Name

Data Type

Field Size

ClassID

Text

Room

Text

TeacherID

Text

20

Click on the box to the left of the ClassID field to select the entire row.
4. Click here to select the
entire row.

5.

Click the Primary Key button to set ClassID as the primary key field.
5. Click the Primary Key
button here.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

6.

Creating Relationships

Close the Design View window and save the new table as Classes.
6. Name the table
Classes and then click
the OK button.

7.

Double-click the Classes table to open it in Datasheet View.

7. Double-click the Classes


table to open it in Datasheet
View.

8.

9.

Enter the following data in the Classes table in Datasheet View.


ClassesID

Room

TeacherID

4A

404

tswong

4B

405

khchan

Close the table in Datasheet View to save the records.

9. Close the table and save


the changes.

10. Similarly, create another table called Teachers with the following table structure.
Field Name

Data Type

Field Size

TeacherID

Text

20

Name

Text

30

StaffRoom

Text

11. Set the TeacherID field as the primary key field.


12. Enter the following data in the Teachers table in Datasheet View.
TeacherID

Name

StaffRoom

tswong

Mr. T. S. Wong

G/F

khchan

Mr. K. H. Chan

1/F

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

Creating Relationships

F. Creating One-to-Many Relationships


1.

Choose Relationships from the Tools menu.


1. Choose Relationships
from the Tools menu.

2.

Choose Show Table from the Relationships menu.


2. Choose Show Table
from the Relationships
menu.

3.

In the Show Table dialog box, Ctrl-click Classes and Teachers, and then click the
Add button to add the two tables to the Relationships window.
3. Add the Classes and
Teachers tables to the
Relationships window.

4.
5.

Click the Close button to close the Show Table dialog box.
In the Relationships window, drag the ClassID field from the Classes table onto
the Class field of the Students table.

5. Drag the ClassID field from the


Classes table onto the Class field of
the Students table.

Designed by T. S. Wong

http://www.wong-sir.com

Microsoft Access 2000 Workshop 3

6.

Creating Relationships

In the Edit Relationships dialog box, click to check all the three options provided
and then click the Create button.
6. Click the Create button
to create a One-to-Many
relationship.

7.

In the Relationships window, drag the TeacherID field from the Teachers table
onto the TeacherID field of the Classes table.

7. Drag the TeacherID field from the


Teachers table onto the TeacherID
field of the Classes table.

8.

In the Edit Relationships dialog box, click to check all the three options provided
and then click the Create button.
8. Click the Create button
to create a One-to-Many
relationship.

9.

Close the Relationships window and save the changes.

G. Exiting Microsoft Access 2000


Choose Exit from the File menu.

Designed by T. S. Wong

http://www.wong-sir.com

You might also like