In this article we will discuss the Comprehensive notes on referential integrity IT class 10. This topic is the part of perform operations on table which is one of the learning outcomes of the Unit 3 Database Management System for IT 402.
Topics Covered
What is referential integrity IT class 10?
As now you are familiar with the terms primary key and foreign key which is used for referential integrity. These keys link more than one table with each other. The referential integrity helps to maintain the accuracy and consistency of data in the relational database.
Sometimes we need to check the redundancy of data and inconsistency of data. A particular record in a table should not be repeated as well as different data should not appear for a single entity in a database.
To do this, relationship between two or more tables are required. For creating relationship between tables a common field between two tables are mandatory.
For example:
A database contains to tables :
- Dept: To store department details
- Emp: To store employees details
Departments
Table
deptno | dname |
10 | HR |
20 | IT |
30 | Accounts |
40 | Marketing |
Emp Table
empno | ename | deptno |
1111 | Kiran Parmar | 10 |
1112 | Mukul Chauhan | 20 |
1113 | Animesh Patel | 30 |
1114 | Bhavin Mishra | 40 |
Important Facts to be known about referential integrity:
- The common columns in both table must be same.
- LibreOffice Base doesn’t allow relationship if they are not same.
- The common field in a table which is not repeated is called a primary key. Here deptno is primary key in dept table.
- The common field in another table is called foreign key. Here deptno is foreign key in emp table.
- The table having primary key is called base/parent/master table.
- The table having foreign key is called child/transaction table.
- The record in master is known as known as master record.
- The record in transaction table is known as transaction record.
Let’s start an article referential integrity IT class 10 with its advantages.
Advantages of referential integrity in database
- Add records into the referenced table even there are no matching records in the parent table (Primary Key table)
- Update records automatically when changes made to the parent table
- Delete records from automatically from the parent table
- Allows to retrieve linked data as and when required
- Save the time of database developer
- No need to enter the same data in separate tables
- reduce data entry errors
- Summarize data from related tables
Now we will see the types of relationship in the next section of referential integrity IT class 10.
Types of relationship
There are three types of relationships:
Creating and Editing relationships between table
Now we will see how to create a relationship using OO/LibreOffice base for referential integrity IT class 10. By using relationship we are going to provide a connection or link or association between two tables. Hence it avoids data redundancy, in simple words, data duplicity can be avoided.
Steps to Create a relationship in OO Base
Create table to create relationship with primary key and foreign key. You can create relationship in two ways:
- Through Menu: Insert > New Relation
- Drag and Drop > Drag Primary Key column to related column into the another table
Follow the below given steps to create relationship in OO base.
- Click on Tool > Relationships. A new window appears to add tables in the relationship.
- If tables are not available, click on Insert > Add Tables option or click on Add Tables icon on the taskbar.
- Click on Insert > New Relations. A new window appears to select the Tables, fields, update options, and delete options. Select appropriate fields and options then click on the OK button. If you want to create a relationship using drag and drop click on the field of the primary key of one table and link them with the foreign key of the child table.
Similarly, you can set the relationship of other types as well. When you add a relationship, the relation design window show one line that connects your tables.
In the next section of referential integrity IT class 10 we will discuss remove relationship.
Steps to Create a relationship in LibreOffice Base
Create a table event as follows:
EventID | EventName | Date | Winner | Score | CategoryID |
1 | Soccer | 2024-05-15 | Team A | 3.5 | C003 |
2 | Basketball | 2024-06-20 | Team B | 4.2 | C001 |
3 | Cricket | 2024-07-10 | Team C | 5.1 | C002 |
4 | Volley Ball | 2024-08-25 | Team D | 6.2 | C001 |
5 | Kabaddi | 2024-09-12 | Team E | 5.8 | C003 |
Create table EventCategory as follows:
Category_ID | Category | Teacher_Inc |
C001 | Net Games | Manoj |
C002 | Bat-Ball Games | Rajan |
C003 | Combative Games | Ajay |
Follow these steps to create a relationship in LibreOffice Base:
[1] Click on Tools > Relationships…
[2] A Relationship Design window will open with with add tables dialog box.
[3] Add desired tables to create relationships.
[4] Click on Close button in Add tables dialog box and close it.
[5] Drag the common field CategoryID from category table and drop on to the categoryid of event table.
[6] It will create line between these two tables as follows:
As per relationship rules and principles, ensure these things:
- No unmatched foreign key value should exist in the table.
- If any records is deleted from master table, corresponding transaction table record should be deleted or should be null.
LibreOffice allows these referential integrity options to choose:
Remove Relationship
Removing relationship is quite simple. You can remove this relationship using one of the following:
- Click on connecting line and press delete key.
- Click on connecting line and do right click, then select Delete option.
Edit relationship is quite similar to delete relationship, click on connecting lines and do right click on table and select edit option.
Follow this link to get NCERT solutions for Chapter 10 Working with multiple tables in base.
Follow this link for more important questions on referential integrity in base.
With this I am going to conclude the article referential integrity IT class 10. So I hope you understood the concept very well. Share this article with your groups and share your views or feedback or suggestions through comments.
Feel free to ask your doubts or queries through comments.
Thank you for vising our blog. Keep visiting, Keep Learning.