Download - Database Management Systems (DBMS)
![Page 1: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/1.jpg)
msigwaem http//:msigwaem.ueuo.com/ 1
Database Management Systems (DBMS)
www.desiamore.com/ifm
B. Computer Science and BSc IT Year 1
![Page 2: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/2.jpg)
msigwaem http//:msigwaem.ueuo.com/ 2
ENTITY-RELATIONALSHIP(E-R) MODELING
Outline …
E-R Model
Components of an E-R Model
ERD Conventions
Relationships
![Page 3: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/3.jpg)
msigwaem http//:msigwaem.ueuo.com/ 3
ENTITY-RELATIONALSHIP(E-R) MODELING
E-R Model The Entity-Relationship (E-R) model is a
high-level conceptual data model developed to facilitate database design by (Chen, 1976)
A conceptual model is a set of concepts that describe The structure of a database The associated retrieval and Update transactions on the database
![Page 4: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/4.jpg)
msigwaem http//:msigwaem.ueuo.com/ 4
E-R Model… The main purpose of developing a
high-level data model is To support a user’s perception of the
data and To conceal the more technical aspects
associated with database design. A conceptual data model is
independent of the particular DBMS and hardware platform that is used to implement the database
![Page 5: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/5.jpg)
msigwaem http//:msigwaem.ueuo.com/ 5
E-R Model…
The basic concepts of the E-R model include.. Entity types Relationship types and Attributes
![Page 6: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/6.jpg)
msigwaem http//:msigwaem.ueuo.com/ 6
E-R Model… Entity type
An object or concept that is identified by the organisation as having an independent existence
Represents a set of objects in the real world with the same properties
Has an independent existence and can be an object with a physical (real) existence as employee, student, book, manager, customer, etc and an object with a conceptual (abstract) existence such as sale, inspection, satisfaction, and so on…..
![Page 7: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/7.jpg)
msigwaem http//:msigwaem.ueuo.com/ 7
Components of an E-R Model The E-R model forms the basis of the
Entity Relationship Diagrams (ERDs) The ERD represents the conceptual
view of the database The ERDs represent three main
components entities Attributes relationships
![Page 8: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/8.jpg)
msigwaem http//:msigwaem.ueuo.com/ 8
Components of an E-R Model…
Entity Is the fundamental item in any data
model Is an instance of an entity type that is
uniquely identifiable Each uniquely identifiable instance of an
entity type is also referred to as entity occurrence or entity instance
![Page 9: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/9.jpg)
msigwaem http//:msigwaem.ueuo.com/ 9
Components of an E-R Model… Attribute
An attribute is a single atomic of information that describes something about its named entity
Example BOOK (ISBN, Title, Author, Publisher,
Publication_year, price)STUDENT (Enrolled_No, Name, programme,
stream, Age, sex, etc )These representations are termed as the logical
description of the entity since each one does not include the machine format for the entity and its attribute
![Page 10: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/10.jpg)
msigwaem http//:msigwaem.ueuo.com/ 10
Components of an E-R Model… Attribute…
Each Attribute is associated with a set of values called domain
The domain defines the potential values that an attribute may hold,
Example, if the age of the student in the class is between 14 and 17, then we can define a set of values for the age attribute of the student entity as the set of integers between 14 and 17
A fully developed data model includes domains for each attribute in the E-R model
![Page 11: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/11.jpg)
msigwaem http//:msigwaem.ueuo.com/ 11
Components of an E-R Model…
Attributes can be classified as following Simple Composite Single-valued Multi-valued Derived
![Page 12: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/12.jpg)
msigwaem http//:msigwaem.ueuo.com/ 12
Components of an E-R Model…
Simple Attribute A simple attribute is an attribute
composed of a single component with an independent existence, cannot be further subdivided
Examples of simple attributes include; sex, age, salary etc. Simple attributes are sometimes called
atomic attribute
![Page 13: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/13.jpg)
msigwaem http//:msigwaem.ueuo.com/ 13
Components of an E-R Model… Composite Attribute
Is an attribute composed of multiple components, each with an independent existence.
Some attributes can be further divided to yield smaller components with an independent existence of their own
Example, the address attribute can be composed of components like street number, Area, City, Pin_code, and so on
![Page 14: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/14.jpg)
msigwaem http//:msigwaem.ueuo.com/ 14
Components of an E-R Model…
Composite Attribute..
Address
City Pin_CodeStreetNo………..
![Page 15: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/15.jpg)
msigwaem http//:msigwaem.ueuo.com/ 15
Components of an E-R Model…
Single-Valued Attribute is one that holds a single value for a
single entity Example, the classroom entity has a
single value for the Room_Number and therefore the Room_Number attribute is referred to as being single-valued
![Page 16: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/16.jpg)
msigwaem http//:msigwaem.ueuo.com/ 16
Components of an E-R Model…
Multi-valued Attribute Is one that holds multiple values for a
single entity. Example, a student can have multiple
values for the Hobby attribute –reading, music, movies, and so on.
![Page 17: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/17.jpg)
msigwaem http//:msigwaem.ueuo.com/ 17
Components of an E-R Model…
Derived Attribute A derived attribute is one that
represents a value that is derivable from the value of a related attribute or set of attributes , not necessarily in the same entity
Example, age can be derived from the date-of-birth attribute and therefore they are related
![Page 18: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/18.jpg)
msigwaem http//:msigwaem.ueuo.com/ 18
E-R Diagram Conventions There are conventions for representing
entities and attributes These conventions are;
The entity are represented by a rectangular box with the name of the entity in the box
An attribute is shown as an ellipse attached to a relevant entity by a line and labelled with the attribute name
The entity name is written in uppercase where as the attribute name is written in lowercase
The primary key (key attributes) are underline
![Page 19: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/19.jpg)
msigwaem http//:msigwaem.ueuo.com/ 19
E-R Diagram Conventions…. Conventions…
The attributes are connected using lines to the entities. If the attribute is simple or single valued a single line is used
If the attributes is derived a dotted line is used
If it is multi-valued then double line are used If the attribute is composite, its component
attributes are shown as ellipse emanating from the composite attribute
see an example below
![Page 20: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/20.jpg)
msigwaem http//:msigwaem.ueuo.com/ 20
E-R Diagram Conventions….
Address
City
Pin_CodeStreet
Class
STUDENT
Fax
State
TellNo.
AgeHobby
Name
LastName
DoB
Reg.No
Figure, ERD for the Student entity
FirstName
![Page 21: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/21.jpg)
msigwaem http//:msigwaem.ueuo.com/ 21
Relationships A relationship is an association between
entities. Each relationship is identified so that its
name is descriptive of the relationships Relationships are represented by diamond
shaped symbols with the relationship name inside the diamond.
The two sides of the diamond are connected to the entities it relates
![Page 22: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/22.jpg)
msigwaem http//:msigwaem.ueuo.com/ 22
Relationships…. Example, the figure below shows the
relationship between the entities PUBLISHER and BOOK
A binary relationship exists when two entities are associated
BOOKPUBLISHER publishes BOOKPUBLISHER publishes BOOKPUBLISHER publishes
PUBLISHER-BOOK Relationship
![Page 23: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/23.jpg)
msigwaem http//:msigwaem.ueuo.com/ 23
Relationships….
Terms associated with entities and relationships Degree Cardinality Connectivity Dependency Participation
![Page 24: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/24.jpg)
msigwaem http//:msigwaem.ueuo.com/ 24
Relationships…. Degree
The degree of a relationship indicates the number of associated entities.
A unary relationship exists when an association is maintained within a single entity
Example, consider the entity SUBJECT, consider a situation where to take a particular subject i.e, English, Maths etc
This kind of a relationship is called a unary relationship as represented below
![Page 25: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/25.jpg)
msigwaem http//:msigwaem.ueuo.com/ 25
Relationships….
Requires
SUBJECT
Figure, Unary Relationship
![Page 26: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/26.jpg)
msigwaem http//:msigwaem.ueuo.com/ 26
Relationships…. Ternary Relationship
a ternary relationship exists when there are three entities associated,
Example, the entities TEACHER, SUBJECT and STUDENT are related using a ternary relationship called ‘teaches’ as shown below
![Page 27: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/27.jpg)
msigwaem http//:msigwaem.ueuo.com/ 27
Relationships….
Ternary Relationship…..
STUDENT
TEACHER
TeachesSUBJECT
Figure, A Ternary Relationship
![Page 28: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/28.jpg)
msigwaem http//:msigwaem.ueuo.com/ 28
Relationships….
A quaternary relationship exists when there are four entities associated,
Example, of a quaternary relationship is ‘studies’ where four entities are involved, STUDENT, TEACHER, COURSE_MATERIAL, and SUBJECT as shown below
![Page 29: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/29.jpg)
msigwaem http//:msigwaem.ueuo.com/ 29
Relationships….
SUBJECT
TEACHER
STUDENT COURSE_MATERIALStudies
Figure, A Quaternary Relationship
![Page 30: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/30.jpg)
msigwaem http//:msigwaem.ueuo.com/ 30
Connectivity Relationships can be classified as
One-to-One One-to-Many and Many-to-Many
The term Connectivity is used to describe this relationship classification
E-R indicates the relationship’s connectivity by placing a 1, M or N near the related entities as shown below
![Page 31: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/31.jpg)
msigwaem http//:msigwaem.ueuo.com/ 31
Connectivity….. Example, the relationship are explained as
follows; A MANAGER in the company manages a single
DEPARTMENT (A One-to-One connectivity) A DEPARTMENT can have more than one
EMPLOYEE (a One-to-Many connectivity) The training department of the company offers
many courses to the employees as a part of the employee development program. Each EMPLOYEE can join for more than one COURSE (a many-to-many connectivity)
![Page 32: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/32.jpg)
msigwaem http//:msigwaem.ueuo.com/ 32
Connectivity…..
(a) A One-to-One Relationship
BOOKPUBLISHER publishes BOOKPUBLISHER Manages DEPARTMENTMANAGER Manages
Figure, One-to-One Relationship
11
![Page 33: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/33.jpg)
msigwaem http//:msigwaem.ueuo.com/ 33
Connectivity…..
(b) a One-to-Many Relationship
BOOKPUBLISHER publishes BOOKPUBLISHER Manages EMPLOYEEDEPARTMENT Has
Figure, One-to-Many Relationship
N1
![Page 34: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/34.jpg)
msigwaem http//:msigwaem.ueuo.com/ 34
Connectivity…..
(c) A Many-to-Many Relationship
BOOKPUBLISHER publishes BOOKEMPLOYEE Manages COURSEJoins
Figure, Many-to-Many Relationship
NN
![Page 35: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/35.jpg)
msigwaem http//:msigwaem.ueuo.com/ 35
Cardinality
Cardinality expresses the specific number of entity occurrences associated with one occurrence of the related entity
The actual number of associated entities is governed by the business rules
![Page 36: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/36.jpg)
msigwaem http//:msigwaem.ueuo.com/ 36
Cardinality…..
Example, cardinality in Relationships
One department can have a maximum of 100 employees
BOOKPUBLISHER publishes BOOKPUBLISHER Manages EMPLOYEEDEPARTMENT Has
Figure, One-to-Many Relationship
N1(0,100) (1,1)
![Page 37: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/37.jpg)
msigwaem http//:msigwaem.ueuo.com/ 37
Cardinality….. Example…cardinality in Relationships
Each employee is allowed to join a maximum of 2 courses at a time whilst a company offers 10 courses
BOOKPUBLISHER publishes BOOKPUBLISHER Manages COURSEEMPLOYEE Joins
Figure, Many-to-Many Relationship
NN(0,2) (0,10)
![Page 38: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/38.jpg)
msigwaem http//:msigwaem.ueuo.com/ 38
Dependency Entities are classified as being strong or weak entity
types An entity type that is existence-dependent on some
other entity is called a weak entity type or existence-dependent and
An entity type that is not existence-dependent on some other entity type is called a strong entity type
A weak entity type is dependent on the existence of another entity
Weak entities are also referred to as child, dependent or subordinate entities and strong entities as parent, owner or dominant entities
![Page 39: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/39.jpg)
msigwaem http//:msigwaem.ueuo.com/ 39
Dependency…..
Example, in the following relationship PARENT is a weak entity as it needs the entity EMPLOYEE for its existence
The entities EMPLOYEE , COMPANY etc, are strong entities.
Refer the figure shown below
![Page 40: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/40.jpg)
msigwaem http//:msigwaem.ueuo.com/ 40
Dependency….. Example…
BOOKPUBLISHER publishes BOOKPUBLISHER Manages EMPLOYEECOMPANY Employs
Figure, Weak and Strong Entities
HasPARENT
![Page 41: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/41.jpg)
msigwaem http//:msigwaem.ueuo.com/ 41
Participation There are two ways an entity can participate
in a relationship as totally or partially. The participation is also known as mandatory
or optional. The participation is total (mandatory) if an
entity’s existence requires the existence of an associated entity in a particular relationship
The participation is said to be optional or partial, if the occurrence of one entity does not require the occurrence of another corresponding entity in a relationship
![Page 42: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/42.jpg)
msigwaem http//:msigwaem.ueuo.com/ 42
Participation….. Example, in the relationship “EMPLOYEE
joins COURSE” , it is quite possible for an EMPLOYEE not to take a COURSE, therefore COURSE is optional to the EMPLOYEE,
But a COURSE must be attended by an EMPLOYEE which makes the EMPLOYEE a mandatory entity
An optional entity is shown by drawing a small circle (O) on the side of the optional entity as shown below
![Page 43: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/43.jpg)
msigwaem http//:msigwaem.ueuo.com/ 43
Participation…..
COURSEJoinsEMPLOYEE
Figure, Optional Entities
NN(0,2) (0,10)
![Page 44: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/44.jpg)
msigwaem http//:msigwaem.ueuo.com/ 44
E-R Model..
Example of one-to-one Relationship between the entities EMPLOYEE and CONSULTANT. Here consultant is a special type of the
entity EMPLOYEE –an ISA relationship Similarly, there are one-to-many and
many-to-many relationships
![Page 45: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/45.jpg)
msigwaem http//:msigwaem.ueuo.com/ 45
E-R Model.. Example…
CONSULTANT
EMPLOYEE
Figure, One-to-One Relationship
Emp_No.
Name
Age
Sex
Salary
Emp_No.
Client
Designation
ISA
![Page 46: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/46.jpg)
msigwaem http//:msigwaem.ueuo.com/ 46
E-R Model..
Example, the relationship between EMPLOYEE and DEPARTMENT is one-to-many relationship (assuming that an employee works for only one department and a department can have more than one employee), as shown below
![Page 47: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/47.jpg)
msigwaem http//:msigwaem.ueuo.com/ 47
E-R Model..
DEPARTMENT
EMPLOYEE
Figure, One-to-Many Relationship
Emp_No.
Name
Age
Sex
Salary
Dept_id. Name
![Page 48: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/48.jpg)
msigwaem http//:msigwaem.ueuo.com/ 48
E-R Model..
Example of the many-to-many relationship is the one between AUTHOR and PUBLISHER.
An author can have more than one publisher and a publisher will be publishing books of more than one author, as shown below
![Page 49: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/49.jpg)
msigwaem http//:msigwaem.ueuo.com/ 49
E-R Model..
PUBLISHER
AUTHOR
Figure, Many-to-Many Relationship
Address
Name
Age
Sex
Phone_No.
NameEditor
Address
![Page 50: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/50.jpg)
msigwaem http//:msigwaem.ueuo.com/ 50
E-R Model.. Example, consider a relationship
between the EMPLOYEE and the CONSULTANT entities, CONSULTANT entity cannot exist without the EMPLOYEE, the EMPLOYEE can exist without the CONSULTANT
See the figure below
![Page 51: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/51.jpg)
msigwaem http//:msigwaem.ueuo.com/ 51
E-R Model..
CONSULTANT
EMPLOYEE
Representation of Employee-Consultant Relationship
Name
Emp_No.
Age
Sex
Salary
Emp_No. Designation
Client
Mandatory
Optional
![Page 52: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/52.jpg)
msigwaem http//:msigwaem.ueuo.com/ 52
E-R Model..
Now if we make up the entity lists of these entities can be written asEMPLOYEE (Emp_No., Name, Age, Sex, Salary )CONSULTANT (Emp_No., Client, Designation)DEPARTMENT (Dept_id.,name)AUTHOR (Name, Age, Sex, Address, Phone_No.)PUBLISHER (Name, Address, Editor)
![Page 53: Database Management Systems (DBMS)](https://reader036.vdocuments.mx/reader036/viewer/2022062308/56812a9c550346895d8e59ba/html5/thumbnails/53.jpg)
msigwaem http//:msigwaem.ueuo.com/ 53
Review
Any QuestionsAny Questions