Skip to main content

E-R Diagrams in DBMS

E-R Diagrams in DBMS: Components, Symbols, And Notations: E-R diagram is the short form of “Entity-Relationship” diagram. An e-r diagram efficiently shows the relationships between various entities stored in a database. In this article, we will discuss what are ER Diagram, ER Diagrams Symbols, Notations, Their various components like Entity, Attribute and Relationship.


E-R Diagrams in DBMS: Components, Symbols, And Notations

E-R diagrams are used to model real-world objects like a person, a car, a company etc. and the relation between these real-world objects. An e-r diagram has following features:


  • E-R diagrams are used to represent E-R model in a database, which makes them easy to be converted into relations (tables).
  • E-R diagrams provide the purpose of real-world modeling of objects which makes them intently useful.
  • E-R diagrams require no technical knowledge & no hardware support.
  • These diagrams are very easy to understand and easy to create even by a naive user.
  • It gives a standard solution of visualizing the data logically.

ER Diagrams Symbols, And Notations

Er-Symbols-and-Notations
Er Diagram Symbols and Notations

Components of an E-R diagram

An E-R diagram constitutes of following Components
A. Entity:- Any real-world object can be represented as an entity about which data can be stored in a database. All the real world objects like a book, an organization, a product, a car, a person are the examples of an entity. Any living or non-living objects can be represented by an entity. An entity is symbolically represented by a rectangle enclosing its name.
Entity
Entity
Entities can be characterized into two types:
  • Strong entity: A strong entity has a primary key attribute which uniquely identifies each entity. Symbol of strong entity is same as an entity.

Strong-Entity
Strong Entity
  • Weak entity: A weak entity does not have a primary key attribute and depends on other entity via a foreign key attribute.
Weak-Entity
Weak Entity
B. Attribute:- Each entity has a set of properties. These properties of each entity are termed as attributes. For example, a car entity would be described by attributes such as price, registration number, model number, color etc. Attributes are indicated by ovals in an e-r diagram.
Attribute
Attribute
A primary key attribute is depicted by an underline in the e-r diagram. An attribute can be characterized into following types:
  • Simple attribute:- An attribute is classified as a simple attribute if it cannot be partitioned into smaller components. For example, age and sex of a person. A simple attribute is represented by an oval.
  • Composite attribute:- A composite attribute can be subdivided into smaller components which further form attributes. For example, ‘name’ attribute of an entity “person” can be broken down into first name and last name which further form attributes. Grouping of these related attributes forms a composite attribute. ‘name is the composite attribute in this example.

Composite-Attribute
Composite Attribute
  • Single valued attribute:- If an attribute of a particular entity represents single value for each instance, then it is called a single-valued attribute. For example, Ramesh, Kamal and Suraj are the instances of entity ‘student’ and each of them is issued a separate roll number. A single oval is used to represent this attribute.
  • Multi valued attribute:– An attribute which can hold more than one value, it is then termed as multi-valued attribute. For example, phone number of a person. Symbol of multi-valued attribute is shown below,
Multi-Valued-Attribute
Multi Valued Attribute

  • Derived attribute: A derived attribute calculate its value from another attribute. For example, ‘age’ is a derived attribute if it calculates its value from ‘current date’ & ‘birth date’ attributes. A derived attribute is represented by a dashed oval.
C. Relationships:- A relationship is defined as bond or attachment between 2 or more entities. Normally, a verb in a sentence signifies a relationship.
For example,
  • An employee assigned a project.
  • Teacher teaches a student.
  • Author writes a book.
A diamond is used to symbolically represent a relationship in the e-r diagram.
Relationship
Relationship
Various terms related to relationships
a). Degree of relationship:- It signifies the number of entities involved in a relationship. Degree of a relationship can be classified into following types:
  • Unary relationship:- If only single entity is involved in a relationship then it is a unary relationship. For example, An employee(manager) supervises another employee.
Unary-relationship
Unary relationship
  • Binary relationships:- when two entities are associated to form a relation, then it is known as a binary relationship. For example, A person works in a company. Most of the times we use only binary relationship in an e-r diagram. The teacher-student example shown above signifies a binary relationship.
Other types of relationships are ternary and quaternary. As the name signifies, a ternary relationship is associated with three entities and a quaternary relationship is associated with four entities.
b.) Connectivity of a relationship:- Connectivity of a relationship describes, how many instances of one entity type are linked to how many instances of another entity type. Various categories of connectivity of a relationship are;
  • One to One (1:1) – “Student allotted a project” signifies a one-to-one relationship because only one instance of an entity is related with exactly one instance of another entity type.
One-To-One
One To One
  • One to Many (1:M) – “A department recruits faculty” is a one-to-many relationship because a department can recruit more than one faculty, but a faculty member is related to only one department.
One-to-Many
One to Many
  • Many to One (M:1) – “Many houses are owned by a person” is a many-to-one relationship because a person can own many houses but a particular house is owned only a person.
Many-To-One
Many To One
  • Many to Many (M:N) – “Author writes books” is a many-to-many relationship because an author can write many books and a book can be written by many authors.
Many-To-Many
Many To Many

Comments

Popular posts from this blog

Spring Security with JWT for REST API

Spring is considered a trusted framework in the Java ecosystem and is widely used. It’s no longer valid to refer to Spring as a framework, as it’s more of an umbrella term that covers various frameworks. One of these frameworks is Spring Security , which is a powerful and customizable authentication and authorization framework. It is considered the de facto standard for securing Spring-based applications. Despite its popularity, I must admit that when it comes to single-page applications , it’s not simple and straightforward to configure. I suspect the reason is that it started more as an MVC application -oriented framework, where webpage rendering happens on the server-side and communication is session-based. If the back end is based on Java and Spring, it makes sense to use Spring Security for authentication/authorization and configure it for stateless communication. While there are a lot of articles explaining how this is done, for me, it was still frustrating to set it up for the f...

Why do I need to override the equals and hashCode methods in Java?

  Imagine you have this MyClass first = new MyClass( "a" , "first" ); MyClass second = new MyClass( "a" , "second" ); Override only  equals If only  equals  is overriden, then when you call  myMap.put(first,someValue)  first will hash to some bucket and when you call  myMap.put(second,someOtherValue)  it will hash to some other bucket (as they have a different  hashCode ). So, although they are equal, as they don't hash to the same bucket, the map can't realize it and both of them stay in the map. Although it is not necessary to override  equals()  if we override  hashCode() , let's see what would happen in this particular case where we know that two objects of  MyClass  are equal if their  importantField  is equal but we do not override  equals() . Override only  hashCode If you only override  hashCode  then when you call  myMap.put(first,someValue)  it takes first, calculate...

Java Logger

In Java, logging is an important feature that helps developers to trace out the errors. Java is the programming language that comes with the logging approach. It provides a Logging API that was introduced in Java 1.4 version. It provides the ability to capture the log file. In this section, we are going to deep dive into the Java Logger API. Also, we will cover logging level, components, Logging handlers or appenders, logging formatters or layouts, Java Logger class, What is logging in Java? In Java, Logging is an API that provides the ability to trace out the errors of the applications. When an application generates the logging call, the Logger records the event in the LogRecord. After that, it sends to the corresponding handlers or appenders. Before sending it to the console or file, the appenders format that log record by using the formatter or layouts. Need for Logging It provides the complete tracing information of the application. It records the critical failure if any occur in ...