Professional Documents
Culture Documents
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.
Right-click the Students Table and then 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.
Designed by T. S. Wong
http://www.wong-sir.com
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.
5.
3.
Click on the left of the field name Class to select the entire row.
4.
Designed by T. S. Wong
http://www.wong-sir.com
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.
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
4.
Creating Relationships
In the Relationships window, 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.
6.
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.
Designed by T. S. Wong
http://www.wong-sir.com
Creating Relationships
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.
3.
4.
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
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.
8.
9.
Room
TeacherID
4A
404
tswong
4B
405
khchan
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
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
Creating Relationships
2.
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.
Designed by T. S. Wong
http://www.wong-sir.com
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.
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.
Designed by T. S. Wong
http://www.wong-sir.com