Question:
How can I relate 2 or more records in one file to eachother?
Answer:
There are a few ways to do this. The main and most popular method is to use a technique called foreign keys. For instance, let’s say you have a database with employees and departments. Each employee is assigned to a particular department. Both departments and employees have unique IDs associated with them. To associate an employee with a department, you store the department ID in the same record as the rest of the employee data. By doing this, you accomplish two things:
- The employee is associated with a department, allowing you to produce reports and other useful information.
- The department information is not duplicated on the employee record, allowing for easier updates of both sets of information later.