Chapter 2-Entity Relationship Model
Chapter 2-Entity Relationship Model
Chapter 2-Entity Relationship Model
EC601
CHAPTER TWO
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.
Chen
ERD COMPONENTS
ENTITY
ATTRIBUTE
RELATIONSHIP
CONNECTIVITY / CARDINALITY
ENTITY
ENTITY An object in the real world that is
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
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
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
COMPOSITE An attribute that can be further subdivided attribute (can broken into components parts)
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
STUDENT
Name
Skill
Multivalued: A student can have more than one skill
First Name
Last Name
RELATIONSHIP
RELATIONSHIP
These describe features pertaining to the association between the entities in the relationship
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
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
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.
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.
appointed to
one branch.
Manages
BRANCH
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
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
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