Page 220 - Computer - 10(A&B)
P. 220
Relationship
Relationship are links that associate a field in one table with a field in another table. In RDBMS, you store data in
multiple tables, which are related to one another in such a way that if there is a need, the data can be joined from
these tables and information can be retrieved.
A relationship works by matching a field with the same name in both tables. In most cases, these matching fields
are the primary key from one table that uniquely identifies each records in the second table.
For example, to create a relationship, make two tables one with the name ‘Student details’ that holds information
about student, such as roll no, name, address, and father‘s name, and another table with the name ‘Fees details’
that holds the information about the roll no and fees. You will only take a common field in the second table i.e.,
roll no. By making a link on the common field, you can retrieve the desired set of records from both the tables.
Relationships between tables helps to:
v save time as there is no need to enter the same data in separate tables.
v reduce data-entry errors.
v summarise data from related tables.
Referential Integrity
Referential integrity is used to maintain accuracy and consistency of data in a relationship. In Base, data can be
linked between two or more tables with the help of primary key and foreign key constraints.
Referential integrity helps to avoid:
v Adding records to a related table if there is no associated record available in the primary key table.
v Changing values in a primary key table if any dependent records are present in associated table(s).
v Deleting records from a primary key table if there are any matching related records available in associated
table(s).
Creating Relationship
Let us learn how to create relationships among tables before creating a query using the following tables.
Student Detail table Marksheet table
Step 1: Click on Relationships option in the Tools menu. The Add Tables dialog box appears.
Step 2: Select the tables and click on Add button. Add them one by one and close the Add Table dialog box.
102