The word “relationship” is the key to the power of Open Office Database and other Relational Database Management System (RDBMS)s. The ability to create and act on relationships between tables is the real power of relational databases.
One-to -one: For every record in one of the tables, one corresponding record exists in other table.
One-to-many: For each record in a table, many corresponding records may exist in the related table.
Many-to-many: For each record in table A, many records may exist in table B; or for each record in table B, many records may exist in table A. Many-to-many should not exist in a well-designed database.
An easy way to create a new table that is based on a predefined template using Table Wizard. It is used to create a table to store customers and a table to store orders to create a relationship between students Info or grade table. Follow these steps:
Start Access with a blank database. Name the database Relationship Example.
2. Click the New button on the Tables tab of the Database window. Select the Table Wizard from the list that appears, then click OK. 3. On the first dialog box of the wizard, choose students from the Sample Tables list box. Then move all the fields in the Sample Fields list box to the Fields in My New Table list box . 4. Click the >>button. The dialog box should appear identical to the one show below:
You can add the Students Grade table in a similar manner. Because an existing table is in the database, however, the Table Wizard provides an additional dialog box. In this dialog box, you can establish a relationship between the Students Info table. Follow these steps to create the Students Grade Table , and establish
You are going to create the Students Grade table and afterwards relate this table to Students Info table based on their common field – Students ID . The Student Info table provides the general information about a particular student, and the Student’s Grade table will provide the necessary data to find his average.
Define the following fields and Field Properties .
Set the Students ID . Field set the Field Size to Byte . The remaining field creates their Field Size Property to Long Integer and set the Decimal Places property to 2. 5. Click the File menu, and choose Save . 6. Type Students Grade as the name of the Table, from the Table Name box of the Save as dialog box. 7. Click on the OK button.
6 . The two tables and their fields open for the Relationship window. Position the mouse pointer to the Students ID of the Students Info table. 7. Drag the field to the Student ID field of the Students Info to Students ID of the Student Grade table and release it. 8. Click on Create button, to create a line between these two tables. 9. Close the Relationship window by clicking the Close command from the File menu. 10. Click the Next dialog box to yes button to save the layout changes to the Relationship window.
To store your data, create one table for each type of information that you track. To bring the data from multiple tables together in a query, form, report, or data access page, define relationships between the tables.
means if both related fields are part of the primary key for its table.
means the field form the other table (the look up table) is that table’s primary key. The Lookup table is the table on the ‘one’ aside of the relationship, whereas the base table is on the ‘many’ side. A record in Table 1 could have many matching records in Table 2, but a record in a Table 2 has only one matching record in Table 1.
How to Open the Relationships Window If you’re opening the Relationship window for the first time for this database, or if these relationships haven’t been saved yet in previous uses, a blank Relationships window appears. The Relationships window display tables and the relationships that have been defined between those tables. The relationships are shown by solid lines connecting the key fields of the tables. Add table to the layout using the Show Table dialog box. Close the Show Table dialog box. Choose Relationships1 Shown Direct
Prepared by: Mrs. Jennis N. Articona ICT Teacher MPNAG