Upload
canhiz
View
14
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Data Modelling ETM
Citation preview
1Engineering and Technology Management
Data Modeling and ERD
2Engineering and Technology Management
Business rules
are derived from policies, procedures, events, functions, and other business objects, and state constraints on the organization.
govern how data are handled and stored.
govern creating, updating, and removing data in an information processing and storage system.
ABusiness rule is a statement that defines or constraints some aspects of the business.
3Engineering and Technology Management
Examples
“Every student in the university must have a faculty advisor.”
“A student may register for a section of a course only if s/he has successfully completed the prerequisities for that course.”
“A preferred customer qualifies for a 10 percent discount, unless he has an overdue account balance.”
4Engineering and Technology Management
Business rules
Assert business structure Control/influence business behavior Expressed in terms familiar to end users Automated through DBMS software
5Engineering and Technology Management
Declarative – what, not how Precise – clear, agreed-upon meaning Atomic – one statement Consistent – internally and externally Expressible – structured, natural language Distinct – non-redundant Business-oriented – understood by business
people
Business rules
6Engineering and Technology Management
First proposed by Chen 1976 Several times expanded Different notations available, most notably
Chen originalCrow foot
Entity-Relationship Model
7Engineering and Technology Management
Model is always a simplified depiction of reality Modeling always has a certain purpose
What might be important in one context might be uninteresting in another one
In creating a model, we are abstracting from the full complexity of real life We need to decide on which facts and relations to
keep, and which special cases to strip away
Models and Modeling
8Engineering and Technology Management
E-R model constructs
Entity Type – collection of entities that share common properties or characteristics (often corresponds to a table) Entity instance – a single occurence of an entity type
(often corresponds to a row in a table)
Attribute - property or characteristic of an entity type that is of interest to the organization (often corresponds to a field in a table)
Relationship type – link (association) between entity types (corresponds to primary key-foreign key equivalencies in related tables)
Relationship instance – association between entity instances
9Engineering and Technology Management
Sample E-R diagram
10Engineering and Technology Management
Entity symbols
Relationship symbols
Attribute symbols
A special entity that is also a relationship
Basic E-R notation
11Engineering and Technology Management
Entities
Person: EMPLOYEE, STUDENT, PATIENT
Place: STORE, WAREHOUSE, STATE
Object: MACHINE, BUILDING, AUTOMOBILE
Event: SALE, REGISTRATION, RENEWAL,
RETURN
Concept: ACCOUNT, COURSE, WORK CENTER
12Engineering and Technology Management
What should an entity be?
SHOULD BE: An object that will have many instances in the
database An object that will be composed of multiple
attributes An object that we are trying to model
SHOULD NOT BE: A user of the database system An output of the database system (e.g. a report)
13Engineering and Technology Management
Inappropriate entities
System userSystem user System outputSystem output
Appropriate entities
14Engineering and Technology Management
Entities
Exercise Identify possible entities in the following description. An Airline company wants to store and manage their
data on flights. They own several airplanes, each with a certain number of seats, and have a number of employees. Also they have customers in their frequent flyer program, each has a certain mileage in his/her account. The planes are assigned to certain flights, as well as employees, and customers can buy seats on the flights. Each flight has a destination, a time and date, and a number of miles.
15Engineering and Technology Management
Attributes
Attribute - property or characteristic of an entity type
Classifications of attributes: Simple versus Composite Attribute Single-Valued versus Multivalued Attribute Stored versus Derived Attributes Identifier Attributes
16Engineering and Technology Management
Identifiers (Keys)
Identifier (Key) - An attribute (or combination of attributes) that uniquely identifies individual instances of an entity type
Simple Key versus Composite Key Candidate Key – an attribute that could be a
key…satisfies the requirements for being a key
17Engineering and Technology Management
Characteristics of identifiers
Will not change in value Will not be null No intelligent identifiers (e.g. containing
locations or people that might change) Substitute new, simple keys for long,
composite keys
18Engineering and Technology Management
An attribute broken into component parts
A composite attribute
19Engineering and Technology Management
The key is underlined
Simple key attribute
20Engineering and Technology Management
The key is composed of two subparts
Composite key attribute
21Engineering and Technology Management
Entity with a multivalued attribute (Skill) and derived attribute (Years_Employed)
Derived from date employed and current date
Multivalued: an employee can have more than one skill
22Engineering and Technology Management
An attribute that is both multivalued and composite
23Engineering and Technology Management
Attributes
Exercise Identify possible attributes in the example from last
exercise. Find additional possible attributes. Decide on which attributes would be multi-valued, and which would be candidate keys.
An Airline company wants to store and manage their data on flights. They own several airplanes, each with a certain number of seats, and have a number of employees. Also they have customers in their frequent flyer program, each has a certain mileage in his/her account. The planes are assigned to certain flights, as well as employees, and customers can buy seats on the flights. Each flight has a destination, a time and date, and a number of miles.
24Engineering and Technology Management
Relationships
Relationship Types vs. Relationship Instances The relationship type is modeled as the diamond and
lines between entity types…the instance is between specific entity instances
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)
25Engineering and Technology Management
Degree of relationships
Degree of a Relationship is the number of entity types that participate in it
Unary Relationship Binary Relationship Ternary Relationship
26Engineering and Technology Management
One entity related to another of the same entity type
Entities of two different types related to each other
Entities of three different types related to each other
Degree of relationships
27Engineering and Technology Management
Unary relationships
28Engineering and Technology Management
Binary relationships
29Engineering and Technology Management
Note: a relationship can have attributes of its own
Ternary relationships
30Engineering and Technology Management
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
31Engineering and Technology Management
Cardinality constraints
Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity.
Minimum Cardinality If zero, then optional If one or more, then mandatory
Maximum Cardinality The maximum number
32Engineering and Technology Management
Cardinality
33Engineering and Technology Management
Basic relationship with only maximum cardinalities showing
Mandatory minimum cardinalities
34Engineering and Technology Management
Optional cardinalities with unary degree, one-to-one relationship
35Engineering and Technology Management
Relationship type
Entity and Relationship instances
36Engineering and Technology Management
A binary relationship with an attribute
Here, the date completed attribute pertains specifically to the employee’s completion of a course…it is an attribute of the relationship.
37Engineering and Technology Management
A ternary relationship with attributes
38Engineering and Technology Management
Representing a billofmaterials structure
A unary relationship with an attribute. This has a many-to-many relationship
39Engineering and Technology Management
Examples of multiple relationships – entities can be related to one another in more than one way
Employees and departments
40Engineering and Technology Management
Professors and courses (fixed upon constraint)
Here,max cardinality constraint is 4
41Engineering and Technology Management
Cardinalities
Exercise Find the right cardinalities...
Student
Id Name
Coursetakes
Professor
advises
Textbook
uses
Grade
42Engineering and Technology Management
Cardinalities
Exercise Infer the business rule difference(s) to Bogazici.
What does the first company not support compared to the second one?
CourseProfessor gives
ProductCustomer buys
DateDate Invoice
ProductCustomer buys
Invoice
43Engineering and Technology Management
Strong vs. Weak Entities, andidentifying relationships
Strong entities exist independently of other types of entities has its own unique identifier represented with single-line rectangle
Weak entity dependent on a strong entity…cannot exist on its own does not have a unique identifier represented with double-line rectangle
Identifying relationship links strong entities to weak entities represented with double line diamond
44Engineering and Technology Management
Strong and weak entities
Strong entity Weak entityIdentifying relationship
45Engineering and Technology Management
Supertype / Subtype and Subset
Supertype / Subtype Implements generalisation All attributes of Supertype pertain to Subtypes Normally split on one attribute
Subset Similar, but non-excluse One entity instance can belong to more than one class
46Engineering and Technology Management
Supertype/subtype relationships
47Engineering and Technology Management
ERD
Exercise Model the following situation using ERD. Include
appropriate attributes. A consulting company maintains offices in several
countries. Each office can have several employees assigned, each employee is assigned to one office. Customers offer projects to the company, each project is from one customer. Employees work on the project for a given time and intensity, and can work on more than one project at the same time. A project will have several employees assigned. Each employee has a list of skills. An employee can be either a senior or junior consultant (who has a date for promotion set), a senior one manages several junior one, each junior is assigned to one senior. For each project, there can be several invoices with different amounts and dates.