Database Management System
E-R Data Model
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Design Phases
2
Physical-design
Phase
[Relational Database]
Logical-design Phase
[Relational Schema]
Conceptual-design
Phase
[ER Diagram]
User
Requirements
Specification
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Conceptual Design >> E-R Data Model
▸ Entity-relationship(E-R) data model is used to represent the conceptual design. It maps the meanings and interactions of
real-world enterprises onto a conceptual schema.
▸ The E-R data model perceives the real world as consisting of basic objects, called entities, and relationships among these
objects.
▸ The E-R model has an associated diagrammatic representation, the E-R diagram. E-R diagram can express the overall
logical structure of a database graphically.
▸ Three principal concepts:
▪ Entity sets
▪ Attributes
▪ Relationship sets
▸ We will consider Chen Model Notations for our E-R Diagram.
3
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Components
▸ Entity: It is a real-world object about which we collect data. In other words, it is a definable thing that can have data stored
about it.
▸ Entity Set: An entity set is a set of entities of the same type that share the same properties or attributes.
▸ Attributes: Attributes are descriptive properties of the entities in the entity set. Each entity has its own value for each
attribute.
▸ Relationship: It is an association among several entities.
▸ Relationship Set: It is a set of relationships of the same type.
4
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Components
5
Entity
Entity Set
Attribute Relationship
Relationship Set
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Attributes
6
Simple – Attribute value is atomic and can’t be
divided into subparts.
Composite – Attributes that can be divided into
subparts i.e. other attributes.
Derived – Attributes that can be calculated from
other related attributes.
Multivalued – Attributes having more than one
values (a set of values) for a specific entity.
SimpleAttr
address
street
zipCode
city
age
ContactNo
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Relationship Attributes
7
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
One-to-Many Relationship Set Many-to-Many Relationship Set
E-R Diagram >> Relationship Attributes
8
Descriptive Attribute – Properties/characteristics of a relationship.
This type of attributes can’t be associated with any entity sets that the
relationship set links.
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Superkey – A set of one or more attributes that, taken collectively, allow
us to identify uniquely an entity in the entity set.
Candidate key – A minimal (irreducible) superkey such that no proper
subset of its attributes is also a superkey.
Primary key – The candidate key chosen to be used for identifying entities
and accessing records.
Key attribute – An attribute that is part of a (primary) key.
Partial key/Discriminator – an attribute that when combined with the key
attribute of the owner entity, provides identification for the weak entity.
E-R Diagram >> Keys
9
KeyAttribute
PartialKeyAttr
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Composite key – A key that is composed of more
than one attribute.
Foreign key – An attribute or combination of
attributes in one table whose values must either
match the primary key in another table or be null.
Foreign keys are used to ensure referential
integrity, the condition in which every foreign key
entry must either be null or a valid value in the
primary key of the related table.
Relational Database Keys
10
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Entity Sets
11
Strong Entity Set – has enough attributes to
uniquely identify each entity.
Weak Entity Set – It is one whose existence is
dependent on another (identifying) entity set.
The primary key attributes of the identifying
entity set, along with the discriminator (partial
key) attributes of its own are used to uniquely
identify each weak entity.
customer
id name street city
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Entity Sets
12
Associative Entity Set – This type of entity set is
used in a many-to-many relationship.
When you need a relationship to be involved in a
relationship then the former relationship is
converted to an associative entity.
course
student
enroll
ment
course
student
enroll
ment
teacher
teach
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Example
13
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Relationship Sets
14
Non-Identifying Relationship Set – A relationship where child entity is
existence-independent of parent entity, and primary key of child doesn’t
contain primary key component of parent entity.
In terms of relationship strength, it is also known as weak relationship.
Identifying Relationship Set – A relationship where child entity is
existence-dependent on parent (identifying) entity, and primary key of
child entity contains primary key component of parent entity.
The identifying relationship set should not have any descriptive
attributes, since any such attributes can instead be associated with the
weak entity set.
In terms of relationship strength, it is also known as strong relationship.
RelSet
Identifying
RelSet
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Relationship Sets
15
Recursive Relationship Set – The same entity set
participates more than once in the relationship.
▪ The function that an entity plays in a
relationship is called that entity’s role.
▪ Since entity sets participating in a relationship
set are generally distinct, roles are implicit and
are not usually specified.
▪ However, they are useful when the meaning of
a relationship needs clarification.
Parallel Relationship Set – more than one
relationships between the same entity sets.
Students Courses
Take
TA
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Mapping Cardinalities
16
One-to-one(1:1) – An entity in A is associated
with at most one entity in B, and an entity in B is
associated with at most one entity in A.
Mapping cardinalities, or Cardinality ratios, express the number of entities to which another entity can be associated via a
relationship set.
department
chairperson
chair-
dept
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Mapping Cardinalities
17
One-to-many (1:N) – An entity in A is associated
with any number of entities in B. An entity in B,
however, can be associated with at most one
entity in A.
class
faculty
faculty
-class
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Mapping Cardinalities
18
Many-to-many (M:N) – An entity in A is
associated with any number of entities in B, and
an entity in B is associated with any number of
entities in A.
class
student enroll
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Participation Constraints
19
Total participation – Every member of the entity
set must participate in the relationship
Partial participation – Not all entities in the set
are involved in the relationship. In the previous
example not every professor guides student.
student
professor guides
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Extended E-R Diagram >> Generalization
20
Generalization – It is the process of extracting
common properties from a set of entities and
create a generalized entity from it.
It is a bottom-up approach in which tow or more
entities can be generalized to a higher level
entity if they have some attributes in common.
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Extended E-R Diagram >> Specialization
21
Specialization – an entity is divided into sub-
entities based on their characteristics.
It is a top-down approach where higher level
entity s specialized into two or more lower level
entities.
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Extended E-R Diagram >> Aggregation
22
Aggregation – an ER diagram is not capable of
representing relationship between an entity and
a relationship which may be required in some
scenarios. In those cases, a relationship with its
corresponding entities is aggregated into higher
level entity.
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Practice 1 (Banking Enterprise)
▸ The bank is organized into branches. Each branch is located in a particular city and is identified by a unique name. The
bank monitors the assets of each branch.
▸ Bank employees are identified by their employee-id values. The bank administration stores the name and telephone
number of each employee, the names of the employee’s dependents, and the employee-id number of the employee’s
manager. The bank also keeps track of the employee’s start date and, thus, length of employment.
▸ Bank customers are identified by their customer-id values. The bank stores each customer’s name, and the street and
city where the customer lives. Customers may have accounts and can take out loans. A customer may be associated
with a particular banker, who may act as a loan officer or personal banker for that customer.
▸ Accounts can be held by more than one customer, and a customer can have more than one account. Each account is
assigned a unique account number. The bank maintains a record of each account’s balance, and the most recent date
on which the account was accessed by each customer holding the account.
▸ A loan originates at a particular branch and can be held by one or more customers. A loan is identified by a unique loan
number. For each loan, the bank keeps track of the loan amount and the loan payments. Although a loan payment
number does not uniquely identify a particular payment among those for all the bank’s loans, a payment number does
identify a particular payment for a specific loan. The date and amount are recorded for each payment.
Construct an E-R Diagram for the bank enterprise.
23
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Practice 2 (Company Database)
▸ The company is organized into departments. Each department has a unique name, a unique number, and a particular
employee who manages the department. We keep track of the start date when that employee began managing the
department. A department may have several locations.
▸ A department controls a number of projects, each of which has a unique name, a unique number, and a single location.
▸ We store each employee’s name, social security number, address, salary, gender, and birth date. An employee is
assigned to one department but may work on several projects, which are not necessarily controlled by the same
department. We keep track of the number of hours per week that an employee works on each project. We also keep
track of the direct supervisor of each employee.
▸ We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first
name, gender, birth date, and relationship to the employee.
Draw the E-R Diagram.
24
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Practice 3 (Online Book Store Database)
▸ Every book has a title, isbn, year and price. The store also keeps the author and publisher for any book.
▸ For authors, the database keeps the name, address and the url of their homepage.
▸ For publishers, the database keeps the name, address, phone number and the url of their website.
▸ The store has several warehouses, each of which has a code, address and phone number. The warehouse stocks
several books. A book may be stocked at multiple warehouses. (In previous sentence, we are not referring to a
particular copy of the book. Consider for example “the complete book” for our course. This book may be stocked at
multiple warehouses.) The database records the number of copies of a book stocked at various warehouses.
▸ The bookstore keeps the name, address, email-id, and phone number of its customers.
▸ A customer owns several shopping basket. A shopping basket is identified by a basketID and contains several
books. Some shopping baskets may contain more than one copy of same book. The database records the number of
copies of each book in any shopping basket.
Design an ER diagram for such a bookstore.
25
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
E-R Diagram >> Practice 4 (Blog Management System)
26
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Construct an ER diagram according to the details provided below:
▸ The blog management system maintains each blog writer’s unique email, name, encoded password, gender, date of
birth, join date, length of employment and address. The address field consists of three components: postal code, city
and street name. Every blog writer is hired by only one blog writer as his employer. The visitors may follow more than
one blog writer.
▸ Each of the blogs has blog id, details, date, time and category. One blog may fall under several categories. Here blog
id cannot uniquely identify a specific blog but blog id together with blog writer email can uniquely identify a specific
blog. A blog writer may publish several blogs.
▸ The visitors can see all the blogs published by writers. Each visitor can comment more than one time in each blog
and the system maintains the date, time, content of that blog comment. Visitors can also hit reactions (like/dislike) in
more than one blogs. The system maintains unique visitor email, visitor name and encrypted password for each
visitor.
E-R Diagram >> Practice 5 (League of Villains)
27
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Consider the following Scenario:
The League of Villains is getting more and more prominent. To reduce the dominance of the villains,
hero society is thinking of positioning heroes in regions. However they first need to design a database
with the following conditions:
▸ Heroes have a unique name, a power, strength level and a rank. Villains also have properties similar to heroes. Also,
each villains may have a boss who is also a villain himself.
▸ A hero is responsible for a certain region. A region has latitude, longitude, and population. A region can be terrorized
by multiple villains. However, one villain does not terrorize more than a region.
▸ Heroes and villains often fight. Hero society needs to keep track of the dates and results of thesefights. A hero and a
villain may fight multiple times.
Design an ERD for the scenario.
E-R Diagram >> Practice 6 (Course Mgmt. System)
28
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Consider the following scenario for Course Management System:
▸ The university stores all the student information that includes a unique student id, name, date of birth, address.
Address is stored in the following three sections: street name, postal code and city.
▸ Each course is identified by its unique course code, trimester, course name and course content. One course is
conducted by several faculties and a student can choose several courses in a single trimester.
▸ The university identifies each faculty through their unique employee id. Each faculty also has a particular room no,
name, contact no, email and join date. Each faculty is associated with anonymous reviews of students. Each review
consists of a review id, review details and datetime. The review id can’t identify a particular review among all the
reviews but the review id for a specific faculty can identify a particular review. Each student is also assigned to a
specific faculty for advising purpose.
Design an ER Diagram for the scenario that satisfies all the given requirements.
E-R Diagram >> Practice 7 (Job Portal System)
29
Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
Consider the following scenario for a Job portal:
▸ The job portal manages each user’s profile where each user is represented by his or her name, unique email, address,
date of birth, educational qualifications, job position and job experience. Both recruiters and job seekers are user and
one recruiter can recruit more than one job seeker.
▸ The recruiters can post job openings to the job portal. The job portal keeps track of each posts date, time, contents,
no of viewers. The system also keeps track of which job seeker is interested in which job posts.
▸ Each of the offices is maintained by their unique office id, name, address and contact no. Every user belongs to some
offices as a recruiter or, an employee or, a follower. Each person can provide his or her anonymous review of offices.
Each of the review contains review id, date, time, review details. The review id cannot uniquely identify a particular
review but a review id together with an office id can uniquely identify a particular review.
Design and ER Diagram for the scenario that satisfies all the given requirements.
30
THANKS!
Any questions?
Email : imam@cse.uiu.ac.bd
References:
▪ Database System Concepts by S. Sudarshan, Henry F. Korth, Abraham Silberschatz
▪ Database Systems The Complete Book by Ullman, Widom and Hector
▪ https://www.lucidchart.com/pages/er-diagrams
▪ https://www.vertabelo.com/blog/chen-erd-notation/

DBMS 2 | Entity Relationship Model

  • 1.
    Database Management System E-RData Model Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 2.
    Design Phases 2 Physical-design Phase [Relational Database] Logical-designPhase [Relational Schema] Conceptual-design Phase [ER Diagram] User Requirements Specification Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 3.
    Conceptual Design >>E-R Data Model ▸ Entity-relationship(E-R) data model is used to represent the conceptual design. It maps the meanings and interactions of real-world enterprises onto a conceptual schema. ▸ The E-R data model perceives the real world as consisting of basic objects, called entities, and relationships among these objects. ▸ The E-R model has an associated diagrammatic representation, the E-R diagram. E-R diagram can express the overall logical structure of a database graphically. ▸ Three principal concepts: ▪ Entity sets ▪ Attributes ▪ Relationship sets ▸ We will consider Chen Model Notations for our E-R Diagram. 3 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 4.
    E-R Diagram >>Components ▸ Entity: It is a real-world object about which we collect data. In other words, it is a definable thing that can have data stored about it. ▸ Entity Set: An entity set is a set of entities of the same type that share the same properties or attributes. ▸ Attributes: Attributes are descriptive properties of the entities in the entity set. Each entity has its own value for each attribute. ▸ Relationship: It is an association among several entities. ▸ Relationship Set: It is a set of relationships of the same type. 4 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 5.
    E-R Diagram >>Components 5 Entity Entity Set Attribute Relationship Relationship Set Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 6.
    E-R Diagram >>Attributes 6 Simple – Attribute value is atomic and can’t be divided into subparts. Composite – Attributes that can be divided into subparts i.e. other attributes. Derived – Attributes that can be calculated from other related attributes. Multivalued – Attributes having more than one values (a set of values) for a specific entity. SimpleAttr address street zipCode city age ContactNo Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 7.
    E-R Diagram >>Relationship Attributes 7 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU One-to-Many Relationship Set Many-to-Many Relationship Set
  • 8.
    E-R Diagram >>Relationship Attributes 8 Descriptive Attribute – Properties/characteristics of a relationship. This type of attributes can’t be associated with any entity sets that the relationship set links. Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 9.
    Superkey – Aset of one or more attributes that, taken collectively, allow us to identify uniquely an entity in the entity set. Candidate key – A minimal (irreducible) superkey such that no proper subset of its attributes is also a superkey. Primary key – The candidate key chosen to be used for identifying entities and accessing records. Key attribute – An attribute that is part of a (primary) key. Partial key/Discriminator – an attribute that when combined with the key attribute of the owner entity, provides identification for the weak entity. E-R Diagram >> Keys 9 KeyAttribute PartialKeyAttr Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 10.
    Composite key –A key that is composed of more than one attribute. Foreign key – An attribute or combination of attributes in one table whose values must either match the primary key in another table or be null. Foreign keys are used to ensure referential integrity, the condition in which every foreign key entry must either be null or a valid value in the primary key of the related table. Relational Database Keys 10 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 11.
    E-R Diagram >>Entity Sets 11 Strong Entity Set – has enough attributes to uniquely identify each entity. Weak Entity Set – It is one whose existence is dependent on another (identifying) entity set. The primary key attributes of the identifying entity set, along with the discriminator (partial key) attributes of its own are used to uniquely identify each weak entity. customer id name street city Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 12.
    E-R Diagram >>Entity Sets 12 Associative Entity Set – This type of entity set is used in a many-to-many relationship. When you need a relationship to be involved in a relationship then the former relationship is converted to an associative entity. course student enroll ment course student enroll ment teacher teach Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 13.
    E-R Diagram >>Example 13 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 14.
    E-R Diagram >>Relationship Sets 14 Non-Identifying Relationship Set – A relationship where child entity is existence-independent of parent entity, and primary key of child doesn’t contain primary key component of parent entity. In terms of relationship strength, it is also known as weak relationship. Identifying Relationship Set – A relationship where child entity is existence-dependent on parent (identifying) entity, and primary key of child entity contains primary key component of parent entity. The identifying relationship set should not have any descriptive attributes, since any such attributes can instead be associated with the weak entity set. In terms of relationship strength, it is also known as strong relationship. RelSet Identifying RelSet Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 15.
    E-R Diagram >>Relationship Sets 15 Recursive Relationship Set – The same entity set participates more than once in the relationship. ▪ The function that an entity plays in a relationship is called that entity’s role. ▪ Since entity sets participating in a relationship set are generally distinct, roles are implicit and are not usually specified. ▪ However, they are useful when the meaning of a relationship needs clarification. Parallel Relationship Set – more than one relationships between the same entity sets. Students Courses Take TA Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 16.
    E-R Diagram >>Mapping Cardinalities 16 One-to-one(1:1) – An entity in A is associated with at most one entity in B, and an entity in B is associated with at most one entity in A. Mapping cardinalities, or Cardinality ratios, express the number of entities to which another entity can be associated via a relationship set. department chairperson chair- dept Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 17.
    E-R Diagram >>Mapping Cardinalities 17 One-to-many (1:N) – An entity in A is associated with any number of entities in B. An entity in B, however, can be associated with at most one entity in A. class faculty faculty -class Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 18.
    E-R Diagram >>Mapping Cardinalities 18 Many-to-many (M:N) – An entity in A is associated with any number of entities in B, and an entity in B is associated with any number of entities in A. class student enroll Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 19.
    E-R Diagram >>Participation Constraints 19 Total participation – Every member of the entity set must participate in the relationship Partial participation – Not all entities in the set are involved in the relationship. In the previous example not every professor guides student. student professor guides Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 20.
    Extended E-R Diagram>> Generalization 20 Generalization – It is the process of extracting common properties from a set of entities and create a generalized entity from it. It is a bottom-up approach in which tow or more entities can be generalized to a higher level entity if they have some attributes in common. Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 21.
    Extended E-R Diagram>> Specialization 21 Specialization – an entity is divided into sub- entities based on their characteristics. It is a top-down approach where higher level entity s specialized into two or more lower level entities. Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 22.
    Extended E-R Diagram>> Aggregation 22 Aggregation – an ER diagram is not capable of representing relationship between an entity and a relationship which may be required in some scenarios. In those cases, a relationship with its corresponding entities is aggregated into higher level entity. Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 23.
    E-R Diagram >>Practice 1 (Banking Enterprise) ▸ The bank is organized into branches. Each branch is located in a particular city and is identified by a unique name. The bank monitors the assets of each branch. ▸ Bank employees are identified by their employee-id values. The bank administration stores the name and telephone number of each employee, the names of the employee’s dependents, and the employee-id number of the employee’s manager. The bank also keeps track of the employee’s start date and, thus, length of employment. ▸ Bank customers are identified by their customer-id values. The bank stores each customer’s name, and the street and city where the customer lives. Customers may have accounts and can take out loans. A customer may be associated with a particular banker, who may act as a loan officer or personal banker for that customer. ▸ Accounts can be held by more than one customer, and a customer can have more than one account. Each account is assigned a unique account number. The bank maintains a record of each account’s balance, and the most recent date on which the account was accessed by each customer holding the account. ▸ A loan originates at a particular branch and can be held by one or more customers. A loan is identified by a unique loan number. For each loan, the bank keeps track of the loan amount and the loan payments. Although a loan payment number does not uniquely identify a particular payment among those for all the bank’s loans, a payment number does identify a particular payment for a specific loan. The date and amount are recorded for each payment. Construct an E-R Diagram for the bank enterprise. 23 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 24.
    E-R Diagram >>Practice 2 (Company Database) ▸ The company is organized into departments. Each department has a unique name, a unique number, and a particular employee who manages the department. We keep track of the start date when that employee began managing the department. A department may have several locations. ▸ A department controls a number of projects, each of which has a unique name, a unique number, and a single location. ▸ We store each employee’s name, social security number, address, salary, gender, and birth date. An employee is assigned to one department but may work on several projects, which are not necessarily controlled by the same department. We keep track of the number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee. ▸ We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first name, gender, birth date, and relationship to the employee. Draw the E-R Diagram. 24 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 25.
    E-R Diagram >>Practice 3 (Online Book Store Database) ▸ Every book has a title, isbn, year and price. The store also keeps the author and publisher for any book. ▸ For authors, the database keeps the name, address and the url of their homepage. ▸ For publishers, the database keeps the name, address, phone number and the url of their website. ▸ The store has several warehouses, each of which has a code, address and phone number. The warehouse stocks several books. A book may be stocked at multiple warehouses. (In previous sentence, we are not referring to a particular copy of the book. Consider for example “the complete book” for our course. This book may be stocked at multiple warehouses.) The database records the number of copies of a book stocked at various warehouses. ▸ The bookstore keeps the name, address, email-id, and phone number of its customers. ▸ A customer owns several shopping basket. A shopping basket is identified by a basketID and contains several books. Some shopping baskets may contain more than one copy of same book. The database records the number of copies of each book in any shopping basket. Design an ER diagram for such a bookstore. 25 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU
  • 26.
    E-R Diagram >>Practice 4 (Blog Management System) 26 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU Construct an ER diagram according to the details provided below: ▸ The blog management system maintains each blog writer’s unique email, name, encoded password, gender, date of birth, join date, length of employment and address. The address field consists of three components: postal code, city and street name. Every blog writer is hired by only one blog writer as his employer. The visitors may follow more than one blog writer. ▸ Each of the blogs has blog id, details, date, time and category. One blog may fall under several categories. Here blog id cannot uniquely identify a specific blog but blog id together with blog writer email can uniquely identify a specific blog. A blog writer may publish several blogs. ▸ The visitors can see all the blogs published by writers. Each visitor can comment more than one time in each blog and the system maintains the date, time, content of that blog comment. Visitors can also hit reactions (like/dislike) in more than one blogs. The system maintains unique visitor email, visitor name and encrypted password for each visitor.
  • 27.
    E-R Diagram >>Practice 5 (League of Villains) 27 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU Consider the following Scenario: The League of Villains is getting more and more prominent. To reduce the dominance of the villains, hero society is thinking of positioning heroes in regions. However they first need to design a database with the following conditions: ▸ Heroes have a unique name, a power, strength level and a rank. Villains also have properties similar to heroes. Also, each villains may have a boss who is also a villain himself. ▸ A hero is responsible for a certain region. A region has latitude, longitude, and population. A region can be terrorized by multiple villains. However, one villain does not terrorize more than a region. ▸ Heroes and villains often fight. Hero society needs to keep track of the dates and results of thesefights. A hero and a villain may fight multiple times. Design an ERD for the scenario.
  • 28.
    E-R Diagram >>Practice 6 (Course Mgmt. System) 28 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU Consider the following scenario for Course Management System: ▸ The university stores all the student information that includes a unique student id, name, date of birth, address. Address is stored in the following three sections: street name, postal code and city. ▸ Each course is identified by its unique course code, trimester, course name and course content. One course is conducted by several faculties and a student can choose several courses in a single trimester. ▸ The university identifies each faculty through their unique employee id. Each faculty also has a particular room no, name, contact no, email and join date. Each faculty is associated with anonymous reviews of students. Each review consists of a review id, review details and datetime. The review id can’t identify a particular review among all the reviews but the review id for a specific faculty can identify a particular review. Each student is also assigned to a specific faculty for advising purpose. Design an ER Diagram for the scenario that satisfies all the given requirements.
  • 29.
    E-R Diagram >>Practice 7 (Job Portal System) 29 Mohammad Imam Hossain, Lecturer, Dept. of CSE, UIU Consider the following scenario for a Job portal: ▸ The job portal manages each user’s profile where each user is represented by his or her name, unique email, address, date of birth, educational qualifications, job position and job experience. Both recruiters and job seekers are user and one recruiter can recruit more than one job seeker. ▸ The recruiters can post job openings to the job portal. The job portal keeps track of each posts date, time, contents, no of viewers. The system also keeps track of which job seeker is interested in which job posts. ▸ Each of the offices is maintained by their unique office id, name, address and contact no. Every user belongs to some offices as a recruiter or, an employee or, a follower. Each person can provide his or her anonymous review of offices. Each of the review contains review id, date, time, review details. The review id cannot uniquely identify a particular review but a review id together with an office id can uniquely identify a particular review. Design and ER Diagram for the scenario that satisfies all the given requirements.
  • 30.
    30 THANKS! Any questions? Email :imam@cse.uiu.ac.bd References: ▪ Database System Concepts by S. Sudarshan, Henry F. Korth, Abraham Silberschatz ▪ Database Systems The Complete Book by Ullman, Widom and Hector ▪ https://www.lucidchart.com/pages/er-diagrams ▪ https://www.vertabelo.com/blog/chen-erd-notation/