Upload
lynette-mcdonald
View
220
Download
1
Tags:
Embed Size (px)
Citation preview
Conceptual Data Modeling 4. 1
CSE2132 Database Systems
Week 4 Lecture
Conceptual Data Modeling
Conceptual Data Modeling 4. 2
Aims of Database Design
· Reduce data redundancy.
· Provide stable data structures that can be readily changed with changing user requirements.
· Allow users to make ad hoc requests for data.
· Maintain complex relationships between data elements.
· Support a large variety of decision needs.
Hawryszkiewycz I J (1984) Database Analysis and Design p 2
Conceptual Data Modeling 4. 3
Design Criteria
- data availability
- data reliability
- data currency
- data consistency
- data flexibility
- data efficiency
Verify these criteria are satisfied via technical review
Conceptual Data Modeling 4. 4
Database Design
- the process of developing database structures from user requirements for data
- a structured methodology
Structured Methodology - a number of ordered formalprocesses with known inputs and expected outputs
Objectives
1. derive relationships2. evolve to meet user requirements3. user requests are met within reasonable time limits
Conceptual Data Modeling 4. 5
Conceptual Design in the System LifecycleProject Identification
and Selection
Project Initiationand Planning
Logical design
Analysis
Physical design
Implementation
Maintenance
Conceptual Data Modeling
Enterprise Modeling
Logical Database Design
Physical Database Design
Database Implementation
}
DB Maintenance
Conceptual Data Modeling 4. 6
The Entity-Relationship Model
· Represents major data objects and the relationships between them.
· Widely used commercially in Australia.
· Originated by Chen in 1976 and adapted in the 'Information Engineering' approach.
· An Entity model is composed of textual descriptions of objects and a graphical representation called an Entity Relationship Diagram
Conceptual Data Modeling 4. 7
ER Diagram Notation
Entity
Weak Entity
Relationship
Attribute
Multivalued Attribute
Identifying Relationship
Derived Attribute
Associative Entity
Conceptual Data Modeling 4. 8
Entity Relationship Modelling
Entities form relationships with one another and each entity may be described by one or more attributes.
Customer Sale OrderPlaces
(Placed By)
ENTITY RELATIONSHIP ATTRIBUTE
CUSTOMER
Any person or organization who purchases goods
Customer Number, Customer Name, Customer Phone
Conceptual Data Modeling 4. 9
Entity Type
· Sometimes referred to as an entity set.
· A set of objects about which we wish to store information.
Smith, Jones, Brown
· Entity instances i.e members of the set LECTURER
· Entity Type or Entity Set is a classification of similar instances.
LECTURER
Conceptual Data Modeling 4. 10
Entity Type
In practice Entity Instance is often shortened to 'Instance’ and Entity type is shortened to Entity.
• Entity names should be brief but unambiguous i.e clearly reflect the meaning .
• Entities should be named in the singular and are often recognized as nouns or noun phrases.
• Entities can model any object set of interest i.e physical, conceptual, events etc.
Conceptual Data Modeling 4. 11
Entity Type versus Weak Entity Type• A strong entity type (i.e. an entity type) exists independently of
other entity types.
• A weak entity type is an entity type whose existence depends on some other entity type. The entity type on which the weak entity type depends is called the identifying owner
EMPLOYEE DEPENDENThas
Emp_ID E_Name D_Name D_O_B
Conceptual Data Modeling 4. 12
Attributes• An attribute is a property or characteristic of an entity type that is of interest to
the organization. Years_Employed is a derived attribute. Skill is a multi-valued attribute. Address is a composite attribute
EMPLOYEE
Years_Employed
Employee_ID
Employee_Name
Address
Skill
Date_Employed
Street
Postcode
Conceptual Data Modeling 4. 13
Attribute Types
A data item or element that describes one entity type.
STUDENT RESULT
Student#, Subject Code, Year, Semester, Grade
S1 COT423 1990 1 N
S1 COT423 1990 2 HD
Primary Key or Identifier
Some or all of the attributes describing an entity type which serve to uniquely identify each entity instance.
Conceptual Data Modeling 4. 14
Value Sets or Domains
Each attribute type describes one entity type and is based on an underlying domain or value set.
EMPLOYEE
Emp# Emp-Gender Emp-Name Emp-Hire-Date
E1 Female Jones 20/6/89
DEPENDENT
Emp# Depend-Name Depend-Sex Birthdate
E1 Smith Male 23/6/46
Conceptual Data Modeling 4. 15
Relationship
A named association between two entity types.
CUSTOMER
SALES ORDER
Places
(Placed By)
Entity type
Relationship Type
Entity Type
Conceptual Data Modeling 4. 16
Relationship
CUSTOMER
SALES ORDER
Places
(Placed By)
Relationship names should indicate the role or reason for the association in both directions. A relationship may have attributes.
Conceptual Data Modeling 4. 17
Relationship Instances
· A relationship instance is an association between two entity instances.
CUSTOMER SALES ORDER
Smith Places Order# 651
Jones Places Order# 375
· A relationship type is a classification of relationship instances.
CUSTOMER SALES ORDER
Places
(Placed By)
Conceptual Data Modeling 4. 18
Degree of Relationship
Binary
Binary Employee Salary
Order Part
Employee Employee
Computer Op. System
Software
1 1
1 m
1
m
m
n
m
n
p
is paid
contain
is aleader/member
is aleader/member
runs on
Unary
Ternary
Conceptual Data Modeling 4. 19
Relationship Cardinality (Maximal Cardinalities)
Employee
Project
Leads
(Lead by)
Customer
Sales Order
Places
(Placed by)
Supplier
Item
Supplies
(Supplied by)
One to One One to Many Many to Many
Relationships represent the 'Business Rules' of the organisation.
Conceptual Data Modeling 4. 20
· The entity participation in the relationship may be mandatory or optional.
CUSTOMER SALES ORDER
Places
(Placed By)
· A Customer may place many Sales Orders.
· A Sales Order must be placed by one Customer.
Relationship Cardinality (Minimal Cardinalities)
Conceptual Data Modeling 4. 21
Associative Entity• The presence of a relationship with one or more attributes suggests
that the relationship should perhaps be represented as an entity.
• An associative entity is an entity type that associates the instances of one or more entity types and contains attributes that are peculiar to the relationship between those entity instances.
EMPLOYEE completes COURSE
EMPLOYEE COURSECERTIFICATE
C_No Date_Completed
Conceptual Data Modeling 4. 22
Abstractions in Conceptual Database DesignClassification abstraction: Class BICYCLE (black bicycle, my bicycle .... )
Aggregation abstraction: Aggregation BICYCLE (wheel, seat, handle bar .. )
Generalization abstraction: Generalization VEHICLE(bicycle, car, truck .. )
VEHICLE
BICYCLE CAR
WHEELPEDAL
SEATHANDLEBAR
STANDARD BARSTRAIGHT BAR
RACER BAR
GENERALISATION
AGGREGATION
CLASSIFICATION
Conceptual Data Modeling 4. 23
Synonyms or Aliases
· Be careful to differentiate between things and their names.
ITEM = PART = PRODUCT ???
· SYNONYM or ALIAS
The same object called different names by different people.
· This problem concerns entity types, relationship types and attribute types.
Conceptual Data Modeling 4. 24
Homonyms
· Different things called the same name by different people ??
EMPLOYEE START DATE
· In the Personnel area this may mean the date an employee started with the company.
· In a given department this may mean the date an employee started with the department.
· This problem also concerns entity types, relationships types and attribute types.
Conceptual Data Modeling 4. 25
Identifying Entity Types
· Entity type names are generally nouns or noun phrases.
· Can the entity type be defined in one or two sentences ?
· What are some typical attributes describing the entity type ??
· Which attributes uniquely identify each entity instance ?
Conceptual Data Modeling 4. 26
Identify the Entity Types
ABC COMPANY SALES ORDER
Order # ____________ Order Date __ / __ / __
Customer Name __________________________________
Customer Address________________________________
_________________________________________________
Item# Description Qty-ord Unit-Price Ext-Price
____ _______________ _______ $_______ $_______
____ _______________ _______ $_______ $_______
Conceptual Data Modeling 4. 27
Building an ER Model
· List the major entity types in the system and note the relationship types between them.
· Represent the entity types by named rectangles.
· Identify relationship types between entity types including relationship degree and nature.
Conceptual Data Modeling 4. 28
Entity Type Proforma
Entity Name ________________ Aliases___________________Definition ______________________________________________Purpose ______________________________________________
Name of Entity Super-type _______________________________________Sub-type Predicate _______________________________________
Sub-type Class Disjoint / Overlapping Total / Partial
Number of Instances ___________________________________________Inserts per period ______________ Deletes per period ________
Insert, Update & Delete Procedures
Conceptual Data Modeling 4. 29
Relationship Definition
Entity 1 Name ____________ ____ Entity 2 Name __________________Relationship Name (E1 to E2) _______________ Aliases _______________Relationship Name (E2 to E1) _______________ Aliases _______________
Degree (E1 to E2) 1:1, 1:m, m:1, m:nNature (E1 to E2) M:O, O:M, O:O, M:M
Referential Integrity Rules Cascade (C), Nullify (N), Restrict (R)E1 to E2 Delete ________ Update ________E2 to E1 Delete ________ Update ________
Definition, Description & Purpose
Conceptual Data Modeling 4. 30
Attribute Definition
Entity Name ___________________________
Attribute Name Domain Name Primary Foreign Key Nulls Default Validation Rules Key References OK Value
Conceptual Data Modeling 4. 31
Domain Definition
Domain Name ___________________ Aliases _______________________Definition ____________________________________________________
Valid Values and Meanings ________________________________________________________________________________________________________
Data Type ________ Size ________
Validation Rules
Comments
Conceptual Data Modeling 4. 32
ER Modelling Exercises
For each of the following problems prepare an Entity Relationship diagram. For relationship types you should name the relationship in both directions;indicate the degree i.e. 1:1, 1:m, m:n; and the nature i.e optional or mandatory. Entity types should be defined in one or two sentences and some possible attribute types identified together with the likely primary key of the entity type. You should also attempt to identify some of the domains or value sets on which the attribute types are based.
1. A Company is made up of several Divisions with each Division employing many Salespersons. Salespersons write many Orders with each Order relating to only one Salesperson and one Customer. Many Items may be ordered on an Order and a given Item may appear on many Orders.
2. The Pearcey Centre for Computing runs a number of evening Courses with each course being identified by a four character course code. Each course runs at a certain time on a certain evening. Students may enrol in any number of courses concurrently provided the courses are not running at the same time on the same evening.
Conceptual Data Modeling 4. 33
A Possible Answer to 1.
1. A Company is made up of several Divisions with each Division employing many Salespersons. Salespersons write many Orders with each Order relating to only one Salesperson and one Customer. Many Items may be ordered on an Order and a given Item may appear on many Orders.
Company
Division Salesperson
Item
Order
Customer
has
employs
belongs to(contains many)
places