0% found this document useful (0 votes)
3 views

Working With Multiple Tables Notes Readers Venue_compressed

The document provides instructions on editing, deleting, and renaming tables in a database, as well as establishing relationships between them. It outlines different types of relationships (one-to-one, one-to-many, many-to-many) and their advantages, such as preventing data redundancy and ensuring data integrity. Additionally, it explains how to maintain referential integrity with options for handling related records during updates or deletions.

Uploaded by

pro gamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Working With Multiple Tables Notes Readers Venue_compressed

The document provides instructions on editing, deleting, and renaming tables in a database, as well as establishing relationships between them. It outlines different types of relationships (one-to-one, one-to-many, many-to-many) and their advantages, such as preventing data redundancy and ensuring data integrity. Additionally, it explains how to maintain referential integrity with options for handling related records during updates or deletions.

Uploaded by

pro gamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Editing and Deleting Tables

To edit a table, open the Database User Interface window.


Right click on the table name and select Edit option from the pop menu.
To delete a table, right click on the table to be deleted, and select the Delete
option from the pop up menu.
A confirmation box will be displayed, click on Yes button delete the table.
To rename a table, right click on the table name in the Table Area and select
Rename option from the pop up menu. Type the new name & press the Enter key.
Relationships between Tables
The most important prerequisite for setting a relationship is that there must be
a common field(s) between the two tables to create a relationship.

PRIMARY KEY MASTER TABLE

MASTER Record

Transaction table
PRIMARY KEY

Transaction
Record
Foreign Key
Types of Relationships

One specific record of a master table has one and only


One-to-One one corresponding record in the transaction table.
Types of Relationships

One specific record of the master table has more than one
One-to-Many corresponding records in the related transaction table.
Types of Relationships

There are multiple records in the master table that


Many-to-Many correspond to multiple records in the transaction table.
Advantages of Relating Tables in a Database
A relationship can help prevent data redundancy.
It helps prevent missing data by keeping deleted data from getting out of sync.
Creating relationships between tables restrictsthe user from entering invalid
data in the referenced fields.
Any updation in the master table is automatically reflected in the transaction tables.
Creating Relationships between Tables
Step 1: From main menu, click on Tools > Relationships
Step 2: The Relationship Design screen will appear.
In the middle of the screen there is Add Tables dialog box. Events

Step 3: Add Events table and EventCategory table to


the Relationship Area.
Step 4: Close the Add Tables dialog box. The tables
Events and EventCategory table will added to the
Relationship Area along with all its field. EventCategory
Step 5: Drag the common field CategoryID from the
Events table and drop it in EventCategory table.
A line connecting both the tables with the common
field (CategoryID) appears on the screen.
Master Table & Transaction Table
Primary Key
EventCategory

Referenced
table

Foreign Key
Primary Key
Event

Referencing
table
Referential Integrity
According to the principle of referential integrity, no unmatched foreign key
values should exist in the database. If a record is removed from the parent table,
the corresponding records in the child table must also be updated or deleted.

LibreOffice Base gives us 4 options to maintain referential integrity:

No action This is the default option. This option states that a user should
not be allowed to update or delete any record in the master
table if any related record exists in the transaction table.

Update cascade This option allows the user to delete or update the
referenced field but along with it all the related records in
any of the transaction tables will also be deleted or updated.
This option assigns NULL value to all the related fields if the master
Set NULL
record is deleted or updated.
This option assigns any fixed default value to all the related fields
Set default
if the master record is deleted or updated.
To set the relationship properties double click on the relation line joining
the two tables. A Relations dialog box will open.
By default the radio button with No action option will be selected.
Choose any of the desired option and click OK to set the referential integrity
between the two tables.

You might also like