Dbms Unit5.
Dbms Unit5.
Dbms Unit5.
Entity
An entity is any singular, identifiable and separate object. It refers to individuals, organizations, systems, bits of data or even distinct
system components that are considered significant in and of themselves. For example, People, Property, Organizations, Agreements
and, etc. In the ER diagram, the entity is represented by a rectangle.
Weak Entity
A weak entity is an entity that depends on the existence of another entity. In more technical terms it can be defined as an entity that
cannot be identified by its own attributes.
Attributes
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB, Age, Address, Mobile_No are
the attributes that define entity type Student. In the ER diagram, the attribute is represented by an oval.
Multi-valued Attribute
If an attribute can have more than one value it is called a multi-valued attribute.
Derived Attribute
An attribute-based on another attribute.
Relationships
A relationship is an association that describes the interaction between entities.
Recursive Relationship
If the same entity participates more than once in a relationship it is known as a recursive relationship.
Cardinality
Cardinality refers to the maximum number of times an instance in one entity can relate to instances of another entity. There are three
types of cardinalities.
1. one to one (1 to 1)
2. one to many(1 to N)
3. many to many (M to N)
Participation
Participation constraint specifies the existence of an entity when it is related to another entity in a relationship type. There are two
types. Partial and Total participation.
Total Participation − Each entity is involved in the relationship. Total participation is represented by double lines.
Partial participation − Not all entities are involved in the relationship. Partial participation is represented by single lines.
Total ParticipationIf at least one member in the superclass does not participate in subclass it is known as partial participation. It
is denoted by one single line.
Partial ParticipationIf all the members in the superclass participate for only one subclass it is known as disjoint and denoted by
“d”. If all the members in the superclass participate in more than one subclass it is known as overlap and denoted by “o”.
Now it ends, after following all the above steps you can come up with your ER and EER diagrams.😍
Benefits of ER and EER diagrams.
Easy to understand and does not require a person to undergo extensive recently training to be able to work with it and accurately.
Readily translatable to relational tables which can be used to quickly build databases
Can directly be used by database developers as the blueprint for implementing databases in specific software application
It can be applied in other contexts such as describing the different relationships and operations within an organization.
Above it shows an ER diagram with its relationships. You can see there are two strong entities with relationships and a weak entity with a
weak relationship.
When you going to make a relational schema first you have to identify all entities with their attributes. You have to write attributes in
brackets as shown below. Definitely you have to underline the primary keys. In the above DEPENDENT is a weak entity. To make it
strong go through the weak relationship and identify the entity which connects with this. Then you have written that entity’s primary key
inside the weak entity bracket.
Then you have to map the primary key to where you took from as shown below.
3. Map binary one to one relations.Let’s assume that the relationship between CUSTOMER and CARD is one to one.There are three
occasions where one to one relations take place according to the participation constraints.
I. Both sides have partial participation.
When both sides have partial participation you can send any of the entity’s primary key to others. At the same time, if there are attributes
in the relationship between those two entities, it is also sent to other entity as shown above.
Here you can see I have written CUSTID and STARTDATE inside the CARD table. Now you have to map CUSTID from where it
comes. That’s it.🤩
You can see between the relationship and CARD entity it has total participation.
When there is total participation definitely the primary of others comes to this. And also if there are attributes in the relationship it also
comes to total participation side.
If it is one-to-many, always to the many side other entities' primary keys and the attributes in the relationship go to the many side. No
matter about participation. And then you have to map the primary key.
If it is many to many relations you should always make a new relationship with the name of the relationship between the entities.
And there you should write both primary keys of the entities and attributes in the relationship and map them to the initials as shown
below.
6. Map multivalued attributes.
If there are multivalued attributes you have to make a new relationship with a suitable
name and write the primary key of the entity which belongs to the multivalued attribute and also the name of the multivalued attribute as
shown below.
If it is unary and one to one or one to many relations you do not need to make a new relationship you just want to add a new primary key
to the current entity as shown below and map it to the initial. For example, in the above diagram, the employee is supervised by the
supervisor. Therefore we need to make a new primary key as SID and map it to EMPID. Because of SID also an EMPID.
Now let us see how to map relations with more than two entities.
If there are more than three entities for a relationship you have to make a new relation table and put all primary keys of
connected entities and all attributes in the relationship. And in the end, you have to map them as shown below.