Database
Relationship is defined as the connection between the tables in a database.
There are various data basing relationships, and they are as follows:
1.
One-to-One
relationship:
A pair of tables
bears a one-to-one relationship when a single record in the first table is
related to only one record in the second table, and a single record in the
second table is related to only one record in the first table. It can be
implemented as a single table and rarely as two tables with primary and foreign
key relationships. A one-to-one relationship usually (but not always) involves
a subset table.
2.
One-to-Many relationships:
A one-to-many
relationship exists between a pair of tables when a single record in the first
table can be related to one or more records in the second table, but a single
record in the second table can be related to only one record in the first table.
By splitting the data into two tables with primary key and foreign key
relationships. This is by far the most common relationship that exists between
a pair of tables in a database, and it is the easiest to identify. It is
crucial from a data-integrity standpoint because it helps to eliminate
duplicate data and to keep redundant data to an absolute minimum.
3.
Many-to-Many
relationships:
A pair of tables
bears a many-to-many relationship when a single record in the first table can
be related to one or more records in the second table and a single record in
the second table can be related to one or more records in the first table. By
using a junction table with the keys from both the tables forming the composite
primary key of the junction table. This is the second most common relationship
that exists between a pair of tables in a database. It can be a little more
difficult to identify than a one-to-many relationship, so you must be sure to
examine the tables carefully.
4.
Self-Referencing
relationship:
This particular
type of relationship does not exist between a pair of tables. It is instead a
relationship that exists between the records within a table. But it is still
regarded in the design process as a table relationship. A table bears a
self-referencing relationship (also known as a recursive relationship) to
itself when a given record in the table is related to other records within the
table. Similar to its dual-table counterpart, a self-referencing relationship
can be one-to-one, one-to-many, or many-to-many.
One-to-One
A self-referencing
one-to-one relationship exists when a given record in the table can be related
to only one other record within the table.
One-to-Many
A table bears a
self-referencing one-to-many relationship to itself when a given record in the
table can be related to one or more other records within the table.
Many-to-Many
A self-referencing
many-to-many relationship exists when a given record in the table can be
related to one or more other records within the table and one or more records
can themselves be related to the given record.
No comments:
Post a Comment