Database System Concepts 03

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 48

E- R DATA MODEL

2
Overview
 ER Data Model Foreign Key
Relationships
 Types of Entity type
Symbol for Relationships
 Weak Entity Types
Relationships types
 Strong Entity Type 1. Unary Relationship
 Naming Entity Types 2. Binary Relationship
 Symbols Attributes of the
 Attribute Relationship
3. Ternary Relationships
 Types of Attributes
 Symbols for Attributes
3
 Primary Key
ER Data Model (or E-R Model)
The ER model defines the conceptual
view of a database. It works around real-
world entities and the associations among
them.
At view and engineering level, the ER
model is considered as a good option for
designing databases.

4
ER Data Model (or E-R Model)
 An entity-relationship model (e-r model) is a
detailed, logical representation of the data for an
organization or for a business area.
 The E-R model is expressed in terms of entities in the
business environment, the relationships (or
associations) among those entities, and the attributes
(or properties) of both the entities and their
relationships.
 An E-R model is normally expressed as an entity-
relationship diagram (E-R diagram, or ERD), which is
a graphical representation of an E-R model.
5
E-R Model vs. E-R diagram
E-R Diagram:
E-R Model:
A graphical
Logical representation representation of an
of the data for an entity-relationship
organization or for a model.
business area, using
entities for categories
of data and
relationships for
associations between
entities. 6
Major Components of ERD
 Entities
 Attributes
 Relationships

7
Entity
 Term used to mean three different
meanings
 Entity type
 Entity instance
 Entity set

8
Entity Type
 A name/label assigned to
items/objects that exist in an
environment and that have similar
properties
 It could be person, place, event or
even concept
Entity Type
 Distinguishable from other entity types on
the basis of properties
 Identified through abstraction process
 Different from External Entity (Not from un-
related terminology)
Entity Instance & Set

 A particular object belonging to a particular


entity type
 Entity Type: Employee
 Entity Instance: M. Sharif
 Entity Set: All employees
Types of Entity type

Entity types can be classified into


1. Regular/Strong/Independent ETs

2. Weak/Dependent ETs

12
Weak Entity Types

An entity type whose instances cannot exist


without being linked with instances of some
other entity type, i.e.
They cannot exist independently.

13
Strong Entity Type

 A strong/regular entity type is the one


whose instances can exist independently,
i.e., without being linked to other instances
 Strong ETs have their own identity

14
15
Naming Entity Types

 Singular noun recommended


 Organization specific names
 Write in capitals
 Abbreviations can be used.
E.G student enrollment
STD_ENROL

16
Symbols
Reg Entity Type NAME

Weak Entity Type NAME

BOOK BOOK_COPY
17
Attribute

An attribute of an entity type is a defining


property or quality of the instances of that
entity type. Entity instances of same entity
type have the same attributes. (e.g. Student
Identification, Student Name)
 Every attribute has a domain
-Set of possible values for an attribute

18
1. Simple Attributes-

19
2. Composite Attributes-

20
3. Single Valued
Attributes-

21
4. Multi Valued Attributes-

22
5. Derived Attributes-

23
6. Key Attributes-

24
Symbols for Attributes

 Each represented as an oval, linked with


an ET symbol

25
Types of Attributes

 Simple vs. composite


 Single valued vs. multi-valued
 Stored vs. derived

26
Symbols for Attributes

Simple
Composite
Multi-valued
Derived
27
Example

Experience empId empName

EMPLOYEE address

dateHired emp_Qual street houseNo

28
Table
Customers

29
Field (Column)
Customers

a field

30
Record (Row)
Customers

a record

31
Primary Key
Customers

primary key field

Primary key is a unique identifier of records in a table.

Primary key values may be generated manually or automatically.


32
Primary Key
Roles (Performances)

Composite primary key fields

A primary key can consist of more than one field


called composite PK.
33
Foreign Key
primary key field
parent table

Directors

relationship child table


Movies

foreign key field


34
Relationships

 Relationships are the connections and


interactions between the entities instances,
e.g., Program and Student ETs are linked
 Naming Relationships
 Up to you
 If there is no proper name of the association in the
system then participants’ names of abbreviations
are used
 STUDENT and CLASS have ENROLL relationship
 However, it can also be named as STD_CLS
35
Symbol for Relationships

DEPT EMP

STD BOOK
36
Relationships types

 Relationship type can be identified like an


entity type
 Entities involved in a relationship are called
its participants
 Types of the relationships can be established
on the basis of participant ETs

37
 One-to-One Relationships
 One-to-Many Relationships
 Many to One Relationships
 Many-to-Many Relationships

38
39
1.One-to-one:
 One instance from entity set X can be
associated with at most one instance of
entity set Y and vice versa.
 Example: One student can register for
numerous courses. However, all those
courses have a single line back to that
one student. But one at a time.

40
One to one

Deptt HoD

41
2.One-to-many:
 One instance from entity set X can be
associated with multiple instances of
entity set Y, but an entity from entity
set Y can be associated with at least
one entity.
 For example, one class is consisting of
multiple students.

42
43
3. Many to One
 More than one instances from entity set
X can be associated with at most one
instance of entity set Y. However, an
instance from entity set Y may or may
not be associated with more than one
instance from entity set X.
 For example, many students belong to
the same class.
44
45
4. Many to Many:
 One instance from Entity X can be
associated with more than one
Instances from Y and vice versa.
 For example, Students as a group are
associated with multiple faculty
members, and faculty members can be
associated with multiple students.

46
47
Sample ERD

48

You might also like