Sei sulla pagina 1di 21

Software Design & Architecture

Presented By
 Shoaib Khalid FA16-BSE-048
 Muhammad Tayyab FA16-BSE-042
 Ahmed Jamal FA16-BSE-016
 Awais Hameed Rana FA16-BSE-006
 Syed Amar Abbas FA16-BSE-070
1
Over View of ERD

 Def: A logical representation of the data for an organization or for a business area, using
entities for categories of data and relationships for associations between entities that is
represented by some graphical notation.
 Major Elements
 Entities
 Relationships
 Attributes

2
Basic E-R notation (Figure 3-2)

Entity
Attribute
symbols
symbols

A special entity
that is also a Relationship
relationship symbols

Relationship
degrees specify
number of
entity types Relationship
involved cardinalities
specify how
many of each
entity type is
allowed
3
Entities

A person, a place, an object, an event, or a concept in the user


environment about which the organization wishes to maintain data.
Person: EMPLOYEE, STUDENT, PATIENT
Place: STORE, WAREHOUSE, STATE
Object: MACHINE, BUILDING, AUTOMOBILE
Event: SALE, REGISTRATION, RENEWAL
Concept: ACCOUNT, COURSE, WORK CENTER
Entity instance– A single occurrence of an entity type. (often corresponds to a row in a
table)
Entity Type– A collection of entities that share common properties or characteristics.
(often corresponds to a table)

4
Types of Entity
Strong versus weak entity types
 Strong entity type (Independent Entity): An entity that exists independently of other entity
types.
has its own unique identifier
identifier underlined with single-line
Examples include STUDENT, EMPLOYEE, AUTOMOBILE, and COURSE
 Weak entity type (Dependent Entity): An entity type whose existence depends on some
other entity type.
does not have a unique identifier (only a partial identifier)
Partial identifier underlined with double-line
Entity box has double line

5
Strong vs. Weak Entities

6
ERD-Attributes

 A property or characteristic of an entity or relationship type (often corresponds to a field in


a table).
 For Example
 STUDENT: Student ID, Student Name, Home Address, Phone Number, Major
 AUTOMOBILE: Vehicle ID, Color, Weight, Horsepower
 Classifications of attributes:
 Required versus Optional Attributes
 Simple versus Composite Attribute
 Single-Valued versus Multivalued Attribute
 Stored versus Derived Attributes
 Identifier Attributes
7
Classifications of attributes:
 Required versus Optional Attributes
 Required attribute: An attribute that must have a value for every entity (or relationship)
instance with which it is associated.
 Optional attribute: An attribute that may not have a value for every entity (or relationship)
instance with which it is associated.

8
Classifications of attributes:

 Simple versus Composite Attribute


 Composite attribute: An attribute that has meaningful component parts (attributes).
 Simple (or atomic) attribute: An attribute that cannot be broken down into smaller
components that are meaningful to the organization.

An attribute
broken into
component parts

9
Classifications of attributes:

 Single-Valued versus Multivalued Attribute


 Single-valued attribute: An attribute that has one value for a given entity (or relationship)
instance.
 Multivalued attribute: An attribute that may take on more than one value for a given entity
(or relationship) instance.

Entity with multivalued attribute (Skill)

Multivalued
an employee can have
more than one skill

10
Classifications of attributes:

 Stored versus Derived Attributes


 Derived attribute: An attribute whose values can be calculated from related attribute
values.

Entity with derived attribute (Years_Employed)

Derived
from date
employed and
current date
11
ERD-Relationships

Degree of relationships

Entities of two
One entity different types
related to related to each
another of the other
same entity type Entities of three
different types
12
related to each other
ERD-Relationships

Figure 3-12 Examples of relationships of different degrees

a) Unary relationships

13
ERD-Relationships
Figure 3-12 Examples of relationships of different degrees (cont.)

b) Binary relationships

14
ERD-Relationships

Figure 3-12 Examples of relationships of different degrees (cont.)


c) Ternary relationship

15
Note: a relationship can have attributes of its own
ERD-Relationships
Figure 3-11b An associative entity (CERTIFICATE)

Associative entity is like a relationship with an attribute, but it is also considered to be an entity in
its own right.
Note that
Lecture No. 3 the many-to-many cardinality between entities in Figure 3-11a has been16 replaced by two
one-to-many relationships with the associative entity.
E-R Model Constructs – Relationships
Cardinality of Relationships
 One-to-One
 Each entity in the relationship will have exactly one related entity
 One-to-Many
 An entity on one side of the relationship can have many related entities, but an entity
on the other side will have a maximum of one related entity
 Many-to-Many
 Entities on both sides of the relationship can have many related entities on the other
side

17
Sample E-R Diagram (Figure 3-1)

18
Sample E-R Diagram (Figure 3-1)
1. A SUPPLIER may supply many ITEMs (by “may supply,” we mean the supplier may not
supply any items). Each ITEM is supplied by any number of SUPPLIERs (by “is supplied,”
we mean that the item must be supplied by at least one supplier). See annotations in
Figure 2-1 that correspond to underlined words.
2. Each ITEM must be used in the assembly of at least one PRODUCT and may be used in
many products. Conversely, each PRODUCT must use one or more ITEMs.
3. ASUPPLIER may send many SHIPMENTs. However, each shipment must be sent by exactly
one SUPPLIER. Notice that sends and supplies are separate concepts. A SUPPLIER may be
able to supply an item, but may not yet have sent any shipments of that item.
4. A SHIPMENT must include one (or more) ITEMs. An ITEM may be included on several
SHIPMENTs.
5. ACUSTOMER may submit any number of ORDERs. However, each ORDER must be submitted
by exactly one CUSTOMER. Given that a CUSTOMER may not have submitted any ORDERs,
some CUSTOMERs must be potential, inactive, or some other customer possibly without
any related ORDERs.
6. An ORDER must request one (or more) PRODUCTs. A given PRODUCT may not be requested
on any ORDER, or may be requested on one or more orders.
19
Draw ERD

20
Draw ERD

 Assignment: All three entities participate in the Assigned relationship that is


modeled as an associative entity Assignment, since the Assign_Date for each
Chemist’s assignment to a particular project and equipment item must be
tracked.
 However, EQUIPMENT and PROJECT do not need to participate in any
assignments. All entities can have multiple assignments.
21

Potrebbero piacerti anche