ER Diagram
ER Diagram
In ER Model, we disintegrate data into entities, attributes and setup relationships between
entities, all this can be represented visually using the ER diagram.
Components of ER diagram-
. Weak Entity
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to
represent an attribute.
For example, id, age, contact number, name, etc. can be attributes of a
student.
Types of attibutes
a. Key attribute
Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key
attribute.For example, Roll_No will be unique for each student. In ER diagram, key
b. Composite Attribute
c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a
multivalued attribute. The double oval is used to represent multivalued
attribute.
For example, a student can have more than one phone number.
d. Derived Attribute
For example, A person's age changes over time and can be derived from
another attribute like Date of birth.
3. Relationship
A relationship is used to describe the relation between entities. Diamond or
rhombus is used to represent the relationship.
• A weak or identifying relationship exists between the strong and weak entity set.
• It is represented using a double diamond symbol.
Enhanced Entity Relationship Model contains all the features of the Entity Relationship
model. In addition to all that, it also contains features of Subclasses, Superclasses and
Inheritance.
Subclasses
A subclass is a class derived from the superclass. It inherits the properties of the
superclass and also contains attributes of its own. An example is:
Car, Truck and Motorcycle are all subclasses of the superclass Vehicle. They all inherit
common attributes from vehicle such as speed, colour etc. while they have different
attributes also.
Superclasses
A superclass is the class from which many subclasses can be created. The subclasses
inherit the characteristics of a superclass. The superclass is also known as the parent
class or base class.
In the above example, Vehicle is the Superclass and its subclasses are Car, Truck and
Motorcycle.
Inheritance
Inheritance is an important feature of Generalization and Specialization. It allows lower-
level entities to inherit the attributes of higher-level entities.
For example, the attributes of a Person class such as name, age, and gender can be
inherited by lower-level entities such as Student or Teacher. Student or Teacher entity nherits
the properties of the superclass and also contains attributes of its own like rollno and empid.
with symbol.
• For example: Square, Circle, Triangle are the sub class of Shape super class.
Generalization
Generalization is a bottom-up approach in which two lower level entities combine to
form a higher level entity. In generalization, the higher level entity can also combine with
other lower level entities to make further higher level entity.
It's more like Superclass and Subclass system, but the only difference is the approach,
which is bottom-up. Hence, entities are combined to form a more generalised entity, in
other words, sub-classes are combined to form a super-class.
For example, Saving and Current account types entities can be generalised and an
entity with name Account can be created, which covers both.
Specialization
Specialization is opposite to Generalization. It is a top-down approach in which one
higher level entity can be broken down into two lower level entity. In specialization, a
higher level entity may not have any lower-level entity sets, it's possible.
UML Class Diagram
The class diagram depicts a static view of an application.
The main purpose of class diagrams is to build a static view of an application. It is the only
diagram that is widely used for construction, and it can be mapped with object-oriented
languages. It is one of the most popular UML diagrams. Following are the purpose of class
diagrams given below:
Middle Section: The middle section constitutes the attributes, which describe the quality of the class.
The attributes have the following characteristics:
a. The attributes are written along with its visibility factors, which are public (+), private (-),
protected (#), and package (~).
b. operation name in a class denote the visibility of the attribute and
operation.
c.
o Lower Section: The lower section contain methods or operations. It demonstrates how a
class interacts with data.
Relationships
A relationship can be one of the following types:
Cardinality
• one to many
• many to many
Aggregation
Composition
• A special type of aggregation where parts are destroyed when the whole is
destroyed.
Realization
you can understand this as the relationship between the interface and the
implementing class.
Class Diagram Example
A class diagram describing the sales order system is given below.
System