Database Management System One-to-one Relationship

Database Management System One-to-one Relationship The management system of the relational database management system is a consistent association between several tables. A relationship based on the collaboration between these tables is established. The relationship is established by connecting one or more fields of two tables. The fields used to connect two tables usually have the same name, data type, and size.

Database One-to-one Relationship

Database One-to-one Relationship

The different types of relationship database are the following:

  • One-to-one relationship
  • One to many relationships
  • Relationship of many to many

Database of one-to-one relationships

  • There is a one-to-one relationship between two tables when
  • the values coincide ed is known as ferns are known as or are established
  • For each record in the first table, there is only one record in the second table.
  • For each record in the second table, there is only one record in the first table.

Example:

An example of the one-to-one relationship is the following:

The previous example has two Employee and Loan tables. The Employee table contains employee data and the Loan table contains loan information. Both tables contain the EmpID field as the primary key. Each employee can borrow a loan once for the tables to join with a record in the loan table and vice versa. Each EmpID appears once in both tables.

Database of one-to-many relationships

There is a one-to-many relationship between two tables when:

  • For each record in the first table, there are one or more records in the second table.
  • For each record in the second table, there is only one record in the first table.
  • The previous example has two Student and Marks tables. The Student table contains student data and its main key field is RollNo. The Subject table contains the grades of the students in different
  • subjects and its main key consists of two RollNo and Subject fields.

The RollNo field also works as a foreign key in the Marks table. Both tables come together with a one-to-many relationship. It means that for each record in the Student table, there may be one or more records in the Subject table. There are more records in the Matter table compared to a record in the Student table because a student studies many subjects.

Database of many to many relationships:

  • There is a many to many relationships between two tables when:
  • For each record in the first table, there are one or more records in the second table.
  • For each record in the second table, there are one or more records in the first table.
  • A relationship of many to many is more complex than other types of relationships. It is a collection of two one-to-many relationships. The following steps are done to create a many-to-many relationship:
  • Create the two tables to connect using many-to-many relationships.
  • Create a third table known as a junction table.
  • Insert the main fields of two tables in the join table and create a composite primary key consisting of both fields in the join table. Create a one-to-many relationship of both tables with the join table.
  • The many-to-many relationship will be established between both tables.
  • Example An example of the many-to-many relationship is the following:

The previous example has three tables. The Artist table contains data from different artists and its main key is ArtistID. The Album table contains data from different albums. An artist can work on many albums and an album can contain songs by different artists.

Many to many relationships must be established between these tables. A meeting table artist album is created for this purpose. It consists of the main fields of the Artist table and the Album table. The join table is connected to both tables using a one-to-many relationship.

Achieve referential integrity:

Referential integrity states that if a foreign key exists in a relationship, the value of the foreign key must match the value of the primary key of some tuple in its parent relationship. Maintains the defined relationship between relationships when records are added or deleted. Ensures that the data in both relationships are consistent.

Achieve referential integrity:

The integrity of the relationship database can be achieved by creating a relationship between the relationships. In a relationship database, a relationship is called a parental relationship and the other is called a child relationship. The primary relationship contains the primary key and the secondary relation contains the foreign key.

The referential integrity ensures the following:

  • A value entered in the external key field of the daughter relation must exist in the parent key field of the parent relationship.
  • A record of a secondary relationship can not be deleted if there are records. The relationship database management system is a consistent association between several tables.

About the author

Saboor

I'm Abdul Saboor, the owner of the site itwords.org has written articles for IT Words, where I share unique information and quality with everyone.IT Words provides free software, new products, tips and tricks related to blogs, social networks, and technological news. I am also the founder of play.google.com, a platform to download mobile applications.

Computer Operating System Information Technology IT Words The Concepts of information technology words Introduction computer words Information Technology Education Computers And Software Education website provides.

Leave a Comment