Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated into the database design process. To describe how ERD components affect database design and implementation.
DEFINITION
Entity Relationship Diagram (ERD)
A detailed, logical representation of the entities, associations and data elements for an organization or business
DIFFERENCES OF MODEL
Crows Foot Entity Chen
Department Department
Attribute
Department Staff No
Staff No.
Relationship
employs employs 3
Chen Notation
EntityName
Verb Phrase
AttributeName
Represents a set or collection of objects in the real world that share the same properties
named property or characteristic of an entity Association between the instances of one or more entity types
ENTITY
An entity is a thing of interest to a system about which information is kept For example in a Hospital Administration System, some likely entities would include: Patient, Doctor, Operation, Ward Each of these things are of interest to the system and would have data stored about them
ENTITIES EXAMPLES
Examples of entities:
Person: EMPLOYEE, STUDENT, PATIENT Place: STORE, WAREHOUSE Object: MACHINE, PRODUCT, CAR Event: SALE,REGISTRATION, RENEWAL Concept: ACCOUNT, COURSE
CHOOSING ENTITIES
Example A sale always starts with a customer receiving an estimate. The estimate then becomes an order. An order can be for one or more stock items. Each stock item belongs to a certain stock category (e.g. taps, sinks, cupboards etc.)
ATTRIBUTE
An attribute is an item of data held about an entity In computer systems an attribute is a field of information
KEY S
A key attribute uniquely identifies a specific occurrence of an entity This may also be referred to as a primary key Examples of primary keys include:
ISBN Student Number Staff ID
10
10
EXAMPLE
In a Sales System, customer name and address are attributes of the entity customer.
The primary key is likely to be Customer Code or Customer ID as the unique identifier for each customer in the system.
11
11
Primary Key
StaffID
Name
Gender
IC
Staff
Entity
Staff
PK StaffID
Attributes
Name Gender IC
12
13
13
BABYSITTING SYSTEM
Data is used to:
Assign employee to job Determine availability
14
14
BABYSITTING SYSTEM
Employee
15
15
16
CUSTOMER
M
assigned to
JOB
Related to
17
17
TO BE CONTINUED
18
FOREIGN KEY
Definition A foreign key is a relationship or link between two tables which ensures that the data stored in a database is consistent. Example: In the example, there is a link between the Company and Contact tables. The Company table is the parent table in the link. The Contact table is the child: the Company_ID field in the Contact table indicates which Company
19
20
RELATIONSHIPS
DEFINITION: Associations between instances of one or more entity types that is of interest
Relationship name: write
Author
write
Book
An author writes one or more books A book can be written by one or more authors.
21
DEGREE OF RELATIONSHIPS
Degree: number of entity types that participate in a relationship
Three cases
Unary: between two instances of one entity type Binary: between the instances of two entity types Ternary: among the instances of three entity types
22
Connectivity
Cardinality : minimum and maximum number of instances of Entity B that can (or must be)
23
PROFESSOR
teaches
CLASS
How Many??
24
Connectivity
1
PROFESSOR teaches
CLASS
(1,4) Cardinality
(1,1)
25
CONNECTIVITY
Chen Model
1 to represent one M to represent many
1 M
26
BINARY RELATIONSHIPS
1:M relationship Relational modeling ideal Should be the norm in any relational database design
BINARY RELATIONSHIPS
1:1 relationship Should be rare in any relational database design A single entity instance in one entity class is related to a single entity instance in another entity class Could indicate that two entities actually belong in the same table
29
BINARY RELATIONSHIPS
M:N relationships Can be implemented by breaking it up to produce a set of 1:M relationships
31
The M:N Relationship Between STUDENT and CLASS Bowser Accounting 1 (ACCT-211) Intro to Microcomputing (CIS-220)
Smithson
33