Chapter 10: Working with Multiple Tables - Notes
1. Introduction
→ After creating a table in a database, you may need to edit or delete it.
→ When working with more than one table, you often have to set up relationships between
tables to avoid data redundancy and inconsistency.
→ Once relationships are set, updating or adding a record in one table can automatically
reflect in related tables.
2. Editing, Deleting & Renaming Tables
Editing a Table:
→ Open the Database UI window.
→ Select the table object in the database pane.
→ Right-click the table name → select Edit from pop-up menu.
→ The design-view window opens.
→ Make required modifications (add/delete/modify fields).
→ Save the table.
Deleting a Table:
→ Open database UI window.
→ Select the table object.
→ Right-click the table name → select Delete.
→ Confirm deletion.
Renaming a Table:
→ Right-click the table name.
→ Select Rename option.
→ Type new name → Press Enter.
3. Relationships between Tables
→ Helps manage multiple tables effectively and avoid redundancy.
→ Example: Student_Details (master) and Student_Result (transaction).
→ Common field (e.g., Admission_No) must have the same data type.
→ Master table = holds primary key.
→ Transaction table = holds foreign key.
4. Types of Relationships
→ One-to-One: One record in master ↔ one record in transaction.
→ One-to-Many: One record in master ↔ multiple records in transaction.
→ Many-to-Many: Multiple records in master ↔ multiple records in transaction.
5. Advantages of Relating Tables
→ Prevents data redundancy.
→ Maintains referential integrity.
→ Restricts entry of invalid data.
→ Updates in master reflect in related tables.
6. Creating Relationships between Tables (in LibreOffice Base)
→ Click: Tools → Relationships…
→ Relationship Design screen appears.
→ Add Tables dialog box opens.
→ Select tables → click Add → close dialog.
→ Drag common field from one table → drop in other table.
→ Line appears indicating relationship.
7. Removing Relationships
→ Right-click the relationship line → select Delete.
8. Referential Integrity
→ Ensures accuracy and consistency of data.
→ Example: If Admission_No=1001 deleted from master, it must not exist in transaction
table.
Options:
→ No action: prevents delete/update if related records exist.
→ Update cascade: updates/deletes reflected in related tables.
→ Set NULL: related fields set to NULL.
→ Set default: related fields set to default value.
9. Summary
→ Relationships control redundancy and inconsistency.
→ Common field must exist in both tables.
→ Three relationship types: One-to-One, One-to-Many, Many-to-Many.
→ Referential integrity ensures consistency of database.