Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

WHAT ARE RELATIONSHIP IN DATABASE?

Relationship in data base may be defined as:


“A relationship in databases refers to the association
or connection between two or more database tables
(entities). It helps improve table structures and reduce
redundant data. Relationships enable relational
databases to divide and store data in separate tables
while connecting disparate data items.”

Types of relation in database


• One-to-one Relationships
• One-to many Relationships
• Many-to-many Relationships

ONE-TO-ONE RELATIONSHIP
ONE-TO-ONE Relationship may be defined as:
“This type of relationship permits a maximum of
a single record on both sides. In one to one
relation (1:1) the mapping of a single instance
of an entity with a single instance of the other
entity.”

EXAMPLES:
• Your address has a single postal identification
number (PIN) and that PIN refers to a single
geographic region
• One student can check out a book from the
library (and the library book can be checked out
by one student at a time).
• A database might have a "Person" table and a
"Passport" table. Each person can have only one
passport, and each passport is associated with
one person.
• One company has only one CEO and this CEO
represent only this company at a time.
• One book has only one title or book name.

ONE-TO-MANY RELATIONSHIP
ONE-TO-MANY Relationship may be defined as:
“The widely used database relationship is one-to-
many.In one to many relationship (1:N) One record
in one table may have a relationship with one or
more records in the other table. It is feasible when a
foreign key of one table references the primary key of
another.”
EXAMPLES:
• A state includes multiple cities, but the same
cities come under that single state only.
• One author write more than one book or these
books were only written by only one author.
• One teacher teach many students but these
students have only one teacher to a prticular
subject
• A single student may enrol in multiple courses.
• Each department can have multiple employees
but each employees belong to only one
department

MANY-TO-MANY RELATIONSHIP
MANY-TO-MANY Relationship may be defined as:
“Many-to-many database relationships are relatively
uncommon. It is a kind of cardinality that describes
the connection between two entities. in many to many
relation(N:N)Multiple records from one table have a
relation with multiple records from another table.”
EXAMPLES:
• An employee can be assigned to multiple projects
and each project can have multiple employees
working on it .
• A salesperson can have many clients, and each client
might have many salespeople.
• One person can belong to multiple communities and
a community can have many individuals.
• One album can include multiple songs and multiple
artists may get involved in those songs.
• Customer can purchase various products and product
can be puechased by many customers.
• A class have multiple students but a student also
attend multiple classes.

You might also like