Sie sind auf Seite 1von 48

Database System

EC601

MRS. ISMA SHAMSURIA BINTI ISMAIL


Department of Electrical Engineering (LEVEL 1) The Polytechnic of Merlimau, Melaka 019-4211728 ext:1163

CHAPTER TWO

Entity Relationship Model


CLO 1 : Explain the basic concepts of database model using entity-relationship diagram and translating completed data models by applying normalization technique in logical database designs.

DATABASE SYSTEM DESIGN


Customer(CustomerID, Name, Address, ) SalesPerson(EmployeeID, Name, Commission, ) Order(OrderID, OrderDate, CustomerID, EmployeeID, ) OrderItem(OrderID, ItemID, Quantity, Price, ) Item(ItemID, Description, ListPrice, )

User views of data.

Conceptual data model.

Implementation (relational) data model.

Physical data storage.

Class diagram that shows business entities, relationships, and rules.

List of nicely-behaved tables. Use data normalization to derive the list.

Indexes and storage methods to improve performance.

DATABASE DESIGN PROCESS

3 PHASES OF DB DESIGN
1. Conceptual Database Design. Produces the initial model of the mini world in a conceptual data model (e.g., in the ER model). 2. Logical Database Design. Transforms the conceptual schema into the data model supported by the DBMS (e.g., the relational model). 3. Physical Database Design. Design indexes, table distribution, buffer size, etc., to maximize performance of the final system.

THE ENTITY RELATIONSHIP (E-R) MODEL


E-R model A high-level data model that is useful in developing a conceptual design for a database. A graphical representation of an ER model. Represent different types of data and how they relate to each other.

E-R diagram (ERD)

Chen

Crows Foot (Erwin)

DATA MODELING VERSION

ERD COMPONENTS

ENTITY

ATTRIBUTE

RELATIONSHIP

CONNECTIVITY / CARDINALITY

ENTITY
ENTITY An object in the real world that is

distinguishable from other objects.


Example: person, place, object, event, concept ENTITY TYPE A collection of entities that share a common definition ENTITY INSTANCES An occurrence of the particular entity

ENTITY
STUDENT ID_NO COURSE SARAH 1234 ET601 EMIR 5678 ET501

Entity

PROGRAM

DTK

DET

Entity type

Entity instances

EXAMPLE OF ENTITY
TANGIBLE
CONCEPTUAL ACTIVE
Example: Person, Product Example: Course Title Example: Delivery, Registration Example: Delivery, Registration Example: Stock

PERMANENT
VOLATILE

ENTITY NOTATION

ER diagram notation for entity student

STUDENT

Strong vs. Weak Entity Types STRONG Entity Type entity that exists independently of other entity types

WEAK Entity Type entity type whose existence depends on some other entity type

TEAM

ATTRIBUTE
ATTRIBUTE facts, property or characteristic of an entity
type (often corresponds to a field in a table)

All entity instances of a given entity set have the same attributes, but vary in the values of those attributes.
STUDENT ID_NO SARAH 1234 ET601 DTK EMIR 5678 ET501 DET

Attribute

COURSE PROGRAM

field ***ATTRIBUTE DOMAIN = Possible value of an attribute

ATTRIBUTE NOTATION
ER diagram notation for an attribute of an entity type (STUDENT)

No_ID

STUDENT
Name
Program

ATTRIBUTE
DEFINITION A property of an entity or a relationship type CLASSIFICATION Single valued Multi valued Composite Derived Value Set (Domain) Value set specifies the set of values that may be assigned to that attribute for each individual entry

CLASSIFICATIONS OF ATTRIBUTES
SINGLE VALUED MULTI VALUED
An attribute that holds a single value for a single entity Example; The majority of people have only one name.

An attribute that holds multiple values for a single entity. A staff may have 2 tel_no, which are home tel_no and hp tel_no.

COMPOSITE
DERIVED

An attribute that have more than one attributes. An address comprises of city, postcode and state

An attribute that represents a value that is derivable from the value of a related attribute, not necessarily in the same entity. Age can be known from Date_of_birth

ATTRIBUTE VALUE
SIMPLE An attribute that cannot be subdivided

attribute

(cannot broken into smaller components)

COMPOSITE An attribute that can be further subdivided attribute (can broken into components parts)

SIMPLE VS COMPOSITE ATTRIBUTE


No_ID

STUDENT
Name
Program First Name Last Name

Composed of 2 subparts

ATTRIBUTE VALUE
SINGLE_ VALUED attribute An attribute that can have MANY values An attribute that can have ONLY SINGLE value (is not necessarily a simple attribute)

MULTI_ VALUED

attribute

SINGLE VS MULTIVALUE ATTRIBUTE


No_ID

STUDENT
Name
Skill
Multivalued: A student can have more than one skill

First Name

Last Name

RELATIONSHIP
RELATIONSHIP

A set of associations among entity types.

(link between entities)

Relationships can have attributes

These describe features pertaining to the association between the entities in the relationship

Two entities can have more than one type of relationship

between them (multiple relationships)

RELATIONSHIP NOTATION

No_ID

No_ID

LECTURER

teach
verb

STUDENT

Name

Name

RELATIONSHIP NOTATION

No_ID

Member of

No_Team

STUDENT
Leader of Name

TEAM

RELATIONSHIP NOTATION
PurchaseDate No_ID No_ID

LECTURER

order

BOOK

Name

Tittle

TotalCost

DEGREE OF THE RELATIONSHIP

The degree of the relationship is the number of entity classes in the relationship: Two entities have a binary relationship of degree two. Three entities have a ternary relationship of degree three.

BINARY RELATIONSHIP

TERNARY RELATIONSHIP

CONNECTIVITY / CARDINALITY
CONNECTIVITY The classification of the relationship

between entities
CARDINALITY

Assign a specific value (number) to


connectivity

Maximum cardinality is the maximum number of entity instances that can participate in a relationship.

Minimum cardinality is the minimum number of entity instances that must participate in a relationship.

TYPES CONNECTIVITY / CARDINALITY

One-to-One [1:1] Each entity in the relationship will have exactly one related entity One-to-Many [1:N] 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 [N:M] Entities on both sides of the relationship can have many related entities on the other side

TYPES OF RELATIONSHIP
Maximum one X for each Y and
Maximum one X for each Y BUT possibly many Ys for each X Example: One publisher publishes any particular book BUT many books may be published by a publisher.
Possibly many Xs for each Y and vice versa. Example: Every student can take many subjects AND every subject can have many students.

one Y for each X.


Example: One branch has one manager AND every manager is

appointed to
one branch.

ONE TO ONE (1:1)


One branch has one manager AND every manager is appointed to one branch
Manager_No MANAGER Branch_No

Manages

BRANCH

ONE TO MANY (1:M)


Example: One publisher publishes any particular book BUT many books may be published by a publisher
Publisher_No PUBLISHER Book_No

Publishes

BOOK

MANY TO MANY(M:N)
Example: Every student can take many subjects AND every subject can have many students
Student_No STUDENT Subject_No

Register

SUBJECT

CONNECTIVITY / CARDINALITY NOTATION

No_ID

No_ID

LECTURER

teach

STUDENT

Name

Name

RELATION KEYS
CANDIDATE KEY PRIMARY KEY FOREIGN KEY
An attribute or group of attributes that identifies a unique row in a relation One of the candidate keys is chosen to be the primary key

Any of the candidates that is selected to be the key or an attribute that uniquely identifies each row in a relation

An attribute in one table whose values must match the primary key in another table or whose must be null

SHAMSIAH_DEC12

DEVELOPING ER DIAGRAM
IDENTIFY ENTITY IDENTIFY RELATIONSHIP

SKETCH ERD

STATE CARDINALITY CONSTRAINT SPECIFY PRIMARY KEYS ADD ATTRIBUTES

EXAMPLE
A company has several departments. Each department has a supervisor and at least one employee. Employees must be assigned to at least one department. Project will be given to the employee and it will be done in a group. At least one employee is assigned to one project or more. The important data fields are the names of the departments, projects, supervisors and employees, as well as the supervisor and employee number, department code and a unique project number.

SOLUTIONS

SOLUTIONS

SOLUTIONS

SOLUTIONS

SOLUTIONS

SOLUTIONS

SHAMSIAH_DEC12

SOLUTIONS

SOLUTIONS

SOLUTIONS

SOLUTIONS

Das könnte Ihnen auch gefallen