Database & SQL — Part(2) ERD

Rawan ElsayydRawan Elsayyd
5 min read

Hello everyone reading here, I am happy that you are here. I hope you are well and have a beautiful day ♥ I think you are here now after reading the first part and here to continue learning.

We will start with a quick tip about “what is the difference between data and information in the context of databases”.

Data( raw) + processing → information.

I mean, id and name are data, but if you say the number of students enrolled in the database subject, then their number is considered information.

Entity relationship diagram (ERD or CDM):

It focuses on visualizing tables and the relationships between them in the database and can be used as a tool for communicating with team members and stockholders to understand system requirements and clarify the proposed design.

Overall

ERD consists of entities, and each entity has its distinctive features and relationships between the entities.

The first thing when I come to design a database for any organization is to ask about” Input forms”: It is an interface used to enter data into the database.

I ask about ” Input forms” to see the data. I am interested in knowing the attribute not value because it distinguishes each entity from the other.

All this is for the sake of knowing how to design an entity relationship diagram (ERD or CDM). Of course, to better understand how to draw ERD, which depends mainly on the written scenario and the Standard notation, we must adhere to it in drawing.

Let’s apply an example to understand most of the ideas:

The entity

shows the name of the table and is drawn in a rectangular shape.

Note: There is no entity for the project name.

There are two types:

a weak entity, which is dependent.

Its primary key is called a partial key.

a strong, independent entity.

Various types of attributes explain each entity from another, including

→ composite.

like person name consist of → first name + middle name + last name.

composite attribute

→multi-value.

like person name → Real name → nickname.

or person phone → 010……. → 011……..

multi-value attribute.

Note: I may have a multi-value composite Attribute.

multi-value composite Attribute.

→ simple Attribute

simple Attribute

→ simple key Attribute

simple key Attribute

→Calculated or Derived

as long as it gets updated.

Relationships:

Describe how entities are related to each other.

They have several types:

1- one-to-one relationship:

Occurs when each record in the first table is linked to one record in the second table and vice versa.

For example, when a student applies to the university and fills out the application. Each student has only one application and each application is linked to Only one student.

2-one- to -many relationships

Occurs when each record in the first table is linked to records in the second table, and vice versa is not true In this case.

for example, students and departments in the university, where each department contains more than one student, but each student is registered in only one department.

example

3-many to many relationships

any relationship many to many is represented in the form

It occurs when each record in the first table is linked to records in the second table, and vice versa is true here.

Example of a student’s relationship with courses. One course is enrolled by more than one student, and one student is enrolled on more than one course.

4-An unary relationship

that occurs between an entity and itself.

it could be one to one , one to many , many to many.

For example, an entity such as courses at a university. Some courses require other courses for the student to be allowed to register for them.

Finally

we know Standard notation

But there are important terms that you may encounter while reading a scenario, such as

1-mandatory

means that the relationship between the entity and the other entity linked to it is always required, meaning it can't be Null, for example, the student’s relationship with the subjects, the student must register for at least one subject.

2-Optionally

this is the opposite of mandatory. Here, the relationship can be optional between entities. It can become Null. For example, a student with student activities. He can be a registered student activity, and it is possible not.

3-Degree

refers to the number of entities participating in the relationship,

→unary if there is one entity.

→ binary if there are two entities.

→ ternary if there are three entities.

4-cardinality

refers to the number of entities on each side of the relationship, for example, one-to-one, one-to-many, and many-to-many.

wrapping up

Today we learned what ERD is, how to draw it, attribute shapes, types of relationships, and some different terminology. Don’t forget to look at Part One, and God willing, we will continue with a new Story.

References:

That’s it, we’re done. God make your dreams come true ♥

Facebook

LinkedIn

0
Subscribe to my newsletter

Read articles from Rawan Elsayyd directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rawan Elsayyd
Rawan Elsayyd